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
在.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
相关文章推荐
- Android Java概念、关键词理解应用总结-----/*自己编写*/
- Android常用程序总结-----/*自己编写*/
- Android Bluetooth开发总结-----/*自己编写*/
- android ui定义自己的dialog(项目框架搭建时就写好,之后事半功倍)
- Android QQ空间(Apad)项目总结(三)---应用UI框架的搭建!!!
- Android message 消息机制介绍及使用 /*自己编写*/
- android项目知识点总结-(个人习惯 供自己以后参考 请勿评论)
- 把项目中常用的小工具做个总结吧,方便自己以后用到
- android_UI_常用特效总结
- android常用UI控件总结
- Eclipse使用技巧总结-----/*自己编写*/
- android项目中常用技术-自我总结二
- 王立平--android项目的开发设计思路,自己总结的,仅供参考
- android学习总结四:如何编写自己的Android.mk
- Android视频播放项目总结之 把毫秒转化成时、分、秒的工具类(自己分装的)
- android 中常用的功能(自己总结)
- Android项目R文件丢失问题—自己总结
- Android视频播放项目总结之 使用Android中的videoView自己定义,暂停,播放时间,总时间,进度等。
- Android UI 中常用技巧总结
- C 关键字总结-----/*自己编写*/