ImageButton的选择不工作 [英] ImageButton selector not working
本文介绍了ImageButton的选择不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图设置ImageView的选择,但它的不工作
I am trying to set selector for ImageView, but it is not working
我的布局
<LinearLayout
android:id="@+id/actionLayout"
android:orientation="horizontal"
android:background="@color/orange_color"
android:gravity="center_vertical"
android:paddingTop="@dimen/actions_top_bottom"
android:paddingBottom="@dimen/actions_top_bottom"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="@dimen/actions_height"
android:id="@+id/btnNoRecord"
android:scaleType="centerInside"
android:src="@drawable/ic_action_record"
android:onClick="onRecordSwitcherClick"
android:layout_weight="1"
android:background="@drawable/selector"/>
...
</LinearLayout>
我selector.xml
My selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/dark_orange_color"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/orange_color"/>
</shape>
</item>
</selector>
在哪里错误?也许有一些错误的LinearLayout里面的属性?
Where is bug? Maybe there is something bug inside LinearLayout properties?
修改
我刚刚发现的ImageButton的LinearLayout以外工作的罚款。但我真的需要布局
EDIT I just found ImageButton outside LinearLayout working fine. But i'm really needed layout
推荐答案
我已经解决了!
在我的code,我有
btnNoRecord.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent)
{
...
return true;
}
});
我改变的返回true 为返回false ,它是工作!
这篇关于ImageButton的选择不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文