Android 中的Theme和Style使用,还是比较简单的。

1、 首先在res/values/styles.xml的resource中定义三个样式,分别为:

   

 然后在res/layout文件下的activity_main.xml中的控件中引用刚才定义的Style。

    android:id="@+id/textView1"    style="@style/TextView"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="@string/hello_world" />     android:id="@+id/button1"    style="@style/Button"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_alignLeft="@+id/textView1"    android:layout_below="@+id/editText1"    android:layout_marginTop="18dp"    android:text="@string/hello_world" />     android:id="@+id/editText1"    style="@style/EditText"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_alignLeft="@+id/button1"    android:layout_below="@+id/textView1"    android:layout_marginTop="19dp"    android:ems="10"    android:text="@string/hello_world" />

 

2、Android的Theme的使用

首先在res/values/themes.xml中定义Theme。

<?xml version="1.0" encoding="utf-8"?>"http://schemas.android.com/apk/res/android">         

 然后在AndroidManifest.xml中使用刚才定义的主题。

只要定义application的android:theme属性为style/Theme即可。

    android:allowBackup="true"    android:icon="@drawable/ic_launcher"    android:label="@string/app_name"    android:theme="@style/Theme" >            android:name="com.example.themedemo.MainActivity"        android:label="@string/app_name" >                    "android.intent.action.MAIN" />             "android.intent.category.LAUNCHER" />            

 也可以用setTheme(R.style.Theme)来调用主题。效果图就不上传了。

 


本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/archive/2013/03/14/2959164.html,如需转载请自行联系原作者

更多相关文章

  1. 自定义TabActivity,TabActivity的美化
  2. android4.0自定义标题报错 -----断点记录
  3. Android 自定义progressDialog
  4. 在android里面使用自定义字体
  5. android 发送自定义广播以及接收自定义广播
  6. android中自定义进度条风格

随机推荐

  1. android的socket开发注意事项
  2. Android学习资源-retrofit,eventBus,butter
  3. Android(安卓)自动化测试
  4. 寻找android中的设计模式(一)
  5. Android studio连接Bmob云数据库教程
  6. 使用eclipse创建android工程时得到警告
  7. 《Android》Lesson09-Acitivity的四种启
  8. 【android】LayoutInflater.inflate方法
  9. Android 四大组件,五大存储,六大布局
  10. Android Studio打包Signed APK 碰到的一