按下效果怎么在LinearLayout中怎么不起作用

nbaqqqq 2012-02-12 10:52:03

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/discount_back" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/discount_back"/>
</LinearLayout>



discount_back.xml

<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/jt_1" />
<item android:state_selected="true" android:drawable="@drawable/jt_1" />
<item android:state_pressed="true" android:drawable="@drawable/jt_1" />
<item android:drawable="@drawable/jt" />
</selector>


按钮的按下效果起作用,但LinearLayout中按下效果就没用,不知道为什么,求解,thanks

...全文
213 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nbaqqqq 2012-02-12
  • 打赏
  • 举报
回复
有作用,非常感谢!
danielinbiti 2012-02-12
  • 打赏
  • 举报
回复
LinearLayout中加上
android:clickable="true"
android:focusable="true"

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧