有时候,可能觉得系统提供的控件太丑,就会需要自定义控件来实现自己想要的效果。以下主要参考《第一行代码》1.自定义一个标题栏:系统自带的标题栏很丑,且没什么大的作用,所以我们之前会在onCreate()中调用requestWindowFeature(Window.FEATURE_N ...
有时候,可能觉得系统提供的控件太丑,就会需要自定义控件来实现自己想要的效果。
以下主要参考《第一行代码》
1.自定义一个标题栏:
系统自带的标题栏很丑,且没什么大的作用,所以我们之前会在onCreate()中调用requestWindowFeature(Window.FEATURE_NO_TITLE);设置不显示标题栏。
下面自定义一个标题栏,中间显示标题,左右各有一个按钮:
title.
1 <??> 2 3 <LinearLayout ="http://schemas.android.com/apk/res/android" 4 5 android:layout_width="match_parent" 6 7 android:layout_height="wrap_content" 8 9 android:orientation="horizontal"10 11 android:background="#bbbbbb" >12 13 <Button14 15 android:id="@+id/btn_back"16 17 android:text="@string/back"18 19 android:layout_width="wrap_content"20 21 android:layout_height="wrap_content"22 23 android:layout_margin="5dp"24 25 android:layout_gravity="left|center_vertical"26 27 android:textColor="#0099cc"28 29 android:layout_weight="1"/>30 31 <TextView32 33 android:id="@+id/title"34 35 android:layout_width="wrap_content"36 37 android:layout_height="wrap_content"38 39 android:textSize="20sp"40 41 android:textColor="#0099cc"42 43 android:text="@string/this_is_title"44 45 android:layout_gravity="center"46 47 android:gravity="center"48 49 android:layout_weight="2"/>50 51 <Button52 53 android:id="@+id/btn_edit"54 55 android:layout_width="wrap_content"56 57 android:layout_height="wrap_content"58 59 android:text="@string/edit"60 61 android:layout_margin="5dp"62 63 android:layout_gravity="right|center_vertical"64 65 android:textColor="#0099cc"66 67 android:layout_weight="1"/>68 69 </LinearLayout>
原标题:android菜鸟学习笔记13
关键词:Android
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。