制作的LinearLayout的行为像一个按钮
我有我的风格,看起来像一个按钮的LinearLayout,它包含了一些文本/ ImageView的元素。我想使整个的LinearLayout行为就像一个按钮,特别是给它指出,在一个如此定义它时,它是pressed不同的背景。
I have a LinearLayout that I've styled to look like a button, and it contains a few text/ImageView elements. I would like to make the whole LinearLayout act like a button, in particular to give it states that are defined in a so it has a different background when it is pressed.
难道还有比作出的ImageButton整个布局的大小和定位绝对更好的办法?
Is there a better way than making an ImageButton the size of the whole Layout and positioning absolutely?
我就遇到了这个问题,刚才。你必须给的LinearLayout设置为可点击。你可以做到这一点的XML与
I ran into this problem just now. You'll have to set the LinearLayout to clickable. You can either do this in the XML with
android:clickable="true"
或与
yourLinearLayout.setClickable(true);
干杯!