您的位置:首页 > 产品设计 > UI/UE

Android UI 常用项目总结------/*自己编写*/

2016-08-17 17:42 330 查看
1. 页面布局中定义一条分割线:

    在.xml文件中添加

    <View

          andriod:layout_height="2px"               //分割线的高度是2px

          android:background="#FF909090" />   //定义分割线的颜色

2. 对于常用的一些组件样式,可以单独建立一个样式文件,然后在需要的组件中直接调用,这样方便调用及维护。

    定义样式文件---values\styles.xml (在values文件夹下新建.xml文件)

    <resources>

          <style name="msg_style">                                                             //定义样式文件

               <item name="android:textSize">45px</item>                           //文字大小为45像素

               <item name="android:textColor">#FFFF00</item>                  //文字颜色设置为黄色

               <item name="android:autoLink">all</item>                              //显示文本中的链接

               <item name="android:layout_width">fill_parent</item>           //组件宽度为屏幕宽度

               <item name="android:layout_height">wrap_content</item>    //组件高度为文字高度

         </style>

     </resources>

     定义好样式文件后,在需要的组件中就可以根据样式名称调用该样式,如在布局管理器(main.xml)中定义一个TextView组件:

     <LinearLayout

           xmlns:android:="http://schemas:android.com/apk/res/android"

           android:orientation="vertical"

           android:layout_width="fill_parent"

           android:layout_height="fill_parent" >

           <TextView

                  android:id="@+id/msg"

                  style="@styles/msg_style"         // styles为.xml文件的名称,msg_style为样式名称对应上面的样式文件

                  android:text="组件样式测试" />

      </LinearLayout>   

本例可参考《Android开发实战经典》P50 例4-5~例4-6

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: