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

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

  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值