Android 中的Theme和Style使用
来源:互联网 发布:网络课程怎么挂着 编辑:程序博客网 时间:2024/06/05 01:16
Android 中的Theme和Style使用
- 首先在res/values/styles.xml的resource中定义三个样式,分别为:
<style name="TextView"> <item name="android:textSize">38sp</item> <item name="android:textColor">#128</item> <item name="android:shadowRadius">1.0</item> <item name="android:background">#035</item> </style> <style name="EditText"> <item name="android:shadowColor">@android:color/black</item> <item name="android:shadowRadius">1.0</item> <item name="android:background">#312</item> <item name="android:foreground">#432</item> <item name="android:textAppearance">?android:attr/textAppearanceMedium</item> <item name="android:height">80dp</item> </style><style name="Button"> <item name="android:background">@android:drawable/edit_text</item> <item name="android:textAppearance">?android:attr/textAppearanceMedium</item></style>
然后在res/layout文件下的activity_main.xml中的控件中引用刚才定义的Style。
<?xml version="1.0" encoding="utf-8"?><resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme" parent="android:Theme.Light"> <item name="android:windowFullscreen">true</item> <item name="android:windowTitleSize">60dip</item> <item name="android:windowTitleStyle">@style/WindowTitle</item> <item name="android:background">#234</item> </style> <style name="WindowTitle"> <item name="android:singleLine">true</item> <item name="android:shadowColor">#658</item> <item name="android:shadowRadius">2.75</item> </style> </resources>
然后在AndroidManifest.xml中使用刚才定义的主题。只要定义application的android:theme属性为style/Theme即可。
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme" > <activity android:name="com.example.themedemo.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity></application>
也可以用setTheme(R.style.Theme)来调用主题
0 0
- Android 中的Theme和Style使用
- Android 中的style和Theme的使用
- Android中的style和theme
- Android中的style和theme
- Android中的Theme和Style
- Android 中的Theme和Style
- Android中的style和theme
- android使用theme和style
- Android中的样式Style和主题Theme使用示例
- Android中的主题(theme)和样式(style)
- Android中的style和theme的用法
- 说说Android中的style和theme
- Android中的Attr、Style和Theme详解
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- CAShapeLayer
- Redis常用指令
- Redis/Memcached K-V缓存数据库转载地址
- 把一个txt通过特殊的标识分割成多个txt
- java泛型
- Android 中的Theme和Style使用
- osIII任务同时等待多个内核对象
- JS中的prototype
- Android 拨打webView 里面的电话号码的方法
- fastjson把对象转化成json避免$ref
- new/delete和malloc/free的一般区别
- 快递轨迹第三方接口接入(快递鸟)
- Hive计算引擎切换
- mvc精简图示