android如何自定义style
16lz
2021-01-26
1、在resource里自定义style
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>
更多相关文章
- 自定义加载动画的两种实现方式
- GreenDao的更新,不会使数据删除所导致重新创建新表的示例
- android 极光推送 自定义声音
- 五、Fresco——ScaleType focusCrop属性详解
- Android日常知识收集与总结之EditText篇
- Android引路蜂地图开发示例:本地查询
- Android(安卓)CoordinatorLayout高级用法之自定义Behavior
- MapView的apiKey
- Android(安卓)Dialog 示例