1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > android linearlayout背景色 Android LinearLayout 点击背景颜色改变

android linearlayout背景色 Android LinearLayout 点击背景颜色改变

时间:2018-10-04 12:06:01

相关推荐

android linearlayout背景色 Android LinearLayout 点击背景颜色改变

为了更好地用户体验, 当用户点击的时候, 要给用户feedback, 在一个布局中, 点击的时候背景颜色改变, 但我们有时候又没有专门的设计人员,这时候就自己了.如下图:

点击的时候颜色会改变

布局的代码如下

android:orientation="horizontal"

//这里的background下面会说到

android:background="@drawable/layout_white_background"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:clickable="true"

>

android:textSize="16.0sp"

android:textColor="@color/text_light"

android:gravity="center"

android:layout_gravity="top"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="10.0dip"

android:layout_marginTop="10.0dip"

android:text="签名"/>

android:textColor="@color/text_light"

android:gravity="left"

android:layout_width="0.0dip"

android:layout_height="wrap_content"

android:layout_marginLeft="3.0dip"

android:layout_weight="1.0"/>

android:id="@+id/layout_description_more"

android:paddingLeft="5.0dip"

android:layout_width="30.0dip"

android:layout_height="45.0dip">

android:layout_gravity="left|center"

android:layout_width="10.0dip"

android:layout_height="10.0dip"

android:src="@drawable/arrow"

/>

上面中最主要的就是LinearLayout的background, 这里说了点击的时候的背景是什么

xmlns:android="/apk/res/android">

//上面的

//color/lilayout_dark是在colors.xml中定义了的

#fff4f4f4

//color/layout_light

#ffffffff

OK 搞定, 这样点击的时候就会背景不一样了

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。