开发者

Clickable LinearLayout not flashing on click

开发者 https://www.devze.com 2022-12-23 01:47 出处:网络
In my Android app, I have a LinearLayout View that contains other views.The LinearLayout is clickable, but when it is clicked, it does not flash orange like it should.

In my Android app, I have a LinearLayout View that contains other views. The LinearLayout is clickable, but when it is clicked, it does not flash orange like it should.

How can I get it to fl开发者_开发问答ash?


To produce the same flash effect you see when you click a listView item try this in your LinearLayout click handler:

public void onLinearLayoutClick(View v) {

  view.setBackgroundResource(android.R.drawable.list_selector_background);

  ...
}


I think you need to define 2 states for your layout if it is not natively defined for it. Have a look here if you want, it explains how to do it for a button for instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号