android如何自定义style
2016-05-02 17:23
423 查看
1、在resource里自定义style
2、在控件属性中使用自定义style
代码:
1、
使用示例:
2、在控件属性中使用自定义style
代码:
1、
<resources xmlns:android="http://schemas.android.com/apk/res/android"> //style可以通过指定parent属性继承 <style name="AppBaseTheme" parent="android:Theme.Light"> </style> <style name="AppTheme" parent="AppBaseTheme"> </style> //定义style名 <style name="testStyle"> //定义style的属性 <item name="android:textSize">30px</item> <item name="android:textColor">#1110CC</item> <item name="android:width">150dip</item> <item name="android:height">150dip</item> </style> </resources>
使用示例:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView <!-- 使用自定义style --> style="@style/testStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" /> </RelativeLayout>
相关文章推荐
- Android Camera 源码浅析
- 史上最详细Android Studio + NDK范例
- 【Android进阶】Android自定义滑动开关控件,适合所有的android系统
- 百度地图在Android中的使用
- TextView实现跑马灯/两个跑马灯效果
- 在Android中使用ORMLite
- android policy源码阅读(1)-policy,PolicyManager
- Android Studio 如何在res目录下新建layout-large目录
- 日积月累:Proguard进行Android代码混淆
- 【读书笔记】【Android 开发艺术探索】第 2 章 IPC 机制
- 使用maven构建android项目
- Android Studio多渠道批量打包及代码混淆
- 自定义View android 像支付宝支付界面的progress
- Android Studio如何导入第三方工程包
- Android Studio 快捷键
- android小常识
- Android中的多进程模式
- Android学习必用-推荐大牛的博客
- Intent实现简易文件浏览查看器
- Android Studio 下的NDK环境搭建与JNI调用