Android布局之LinearLayout自定义高亮背景的方法
发布时间:2016-12-28 来源:查字典编辑
摘要:本文实例讲述了Android布局之LinearLayout自定义高亮背景的方法。分享给大家供大家参考,具体如下:首先创建linearlayo...
本文实例讲述了Android布局之LinearLayout自定义高亮背景的方法。分享给大家供大家参考,具体如下:
首先创建linearlayout_background.xml文件
res/drawable/linearlayout_background.xml
<"1.0" encoding="utf-8"?> <selectorxmlns:android="http://schemas.android.com/apk/res/android"> <itemandroid:state_pressed="true" android:drawable="@drawable/button_pressed"/> <itemandroid:state_focused="true" android:drawable="@drawable/button_pressed"/> <itemandroid:drawable="@drawable/button_normal"/> </selector>
其次在对应的xml布局文件中
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:clickable="true"<> android:background="@drawable/linearlayout_background"> <Button ....../> <TextView ...../> </LinearLayout>
希望本文所述对大家Android程序设计有所帮助。