<LinearLayout android:descendantFocusability="blocksDescendants">              <Button android:background="@layout/selector" ></LinearLayout>
Button通过设置android:background使得点击时变换背景颜色
但如何实现点击LinearLayout时会触发Button的onClick(就是Button的背景颜色也会变化)

解决方案 »

  1.   

    觉得你这联动不能用selector,考虑考虑设计上吧
      

  2.   

    别用selector,在代码中添加ontouch事件试一下
      

  3.   

    其实你的思路太局限了,imageView和button都是View,大家都有同样的基类,那干嘛一定要用button呢,而且也根本没必要去监听button的OnClick。
    你把Button换成imageView(不换也可以,但是可扩展性不好),然后LinearLayout和imageView都做一个selector,给LinearLayout做一个OnClick监听,绑定在xml里就行了,然后监听里加一行
    你的LinearLayout.setSelected(true)就可以了
      

  4.   

    View view = new View(context);
    Button button = new Button(context);
    view.addView(button);怎样才能在点击button是触发的onClick事件?
      

  5.   

    Button换成View然后只要给LinearLayout写onClick事件就可以了
      

  6.   

    你是不是LinearLayout的Clickable没有设置为true啊
    或者写onTeachlistener也可以