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> 

更多相关文章

  1. 自定义加载动画的两种实现方式
  2. GreenDao的更新,不会使数据删除所导致重新创建新表的示例
  3. android 极光推送 自定义声音
  4. 五、Fresco——ScaleType focusCrop属性详解
  5. Android日常知识收集与总结之EditText篇
  6. Android引路蜂地图开发示例:本地查询
  7. Android(安卓)CoordinatorLayout高级用法之自定义Behavior
  8. MapView的apiKey
  9. Android(安卓)Dialog 示例

随机推荐

  1. android中Acitivity的启动方式启动模式讲
  2. Android(安卓)Makefile中是 如何识别 TAR
  3. android linker 浅析
  4. Android(安卓)Socket 实现
  5. Android(安卓)Display System --- Surfac
  6. Android(安卓)中文 API (27) ―― SeekBar.
  7. android小知识点
  8. Android(安卓)Studio无法调试运行app的解
  9. 为Android内核添加新驱动
  10. ChkBugReport工具 for Android(安卓)1