[android] 安卓自定义样式和主题
2016-07-20 21:01
537 查看
简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上
styles.xml
activity_main.xml
Manifest.xml
styles.xml
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 自定义样式 --> <style name="MyFont"> <item name="android:textColor">#ff0000</item> <item name="android:textSize">40sp</item> </style> <style name="MyFontSon" parent="@style/MyFont"> <item name="android:textSize">30sp</item> </style> <!-- 自定义主题 --> <style name="MyTheme"> <item name='android:windowNoTitle'>true</item> <item name="android:background">#ffffff</item> </style> </resources>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView style="@style/MyFont" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="样式和主题" /> <TextView style="@style/MyFontSon" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="样式和主题" /> </LinearLayout>
Manifest.xml
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="ss" android:theme="@style/MyTheme" >
![](https://images2015.cnblogs.com/blog/726254/201607/726254-20160720205928122-1906583912.jpg)
相关文章推荐
- Android 自定义toggleButton
- android的DeepLink
- android沉浸式
- android欢迎页通知栏隐藏
- 《android开发艺术探索》笔记之Bitmap的加载和Cache
- Android Activity的四大启动模式
- [Android] ImageView.ScaleType设置图解
- android 中ListView Adapter内所蕴含的观察者模式
- android屏幕录制和转gif
- 用draw9patch.bat绘制的气泡图片用在Android程序中有黑线,怎么解决?
- 通过手势实现Android自定义View的缩放
- Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found解决办法
- android developer tiny share-20160720
- android developer tiny share-20160720
- Android--Uri
- android布局嵌套问题
- Android 傻瓜式自动测试 利用AS2.2 Record Espresso + Instrumentation
- Android NDK系列(1) --- 配置及简单使用
- android使用ImageLoader实现图片缓存(安卓开发必备)
- ART探险(1) - oatdump看到的世界