Android - style
2016-03-01 10:49
295 查看
Style(风格):自定义的一些 View 属性集合。
styles.xml
<span style="font-size:14px;"> <style name="TextViewStyle">
<item name="android:textColor">@android:color/holo_blue_dark</item>
<item name="android:textSize">30sp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:gravity">center_horizontal</item>
</style></span>
activity_main.xml
<span style="font-size:14px;"><LinearLayout
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"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!" />
<TextView
style="@style/TextViewStyle"
android:text="TV1" />
<TextView
style="@style/TextViewStyle"
android:text="TV2" />
<TextView
android:text="TV1"
android:textColor="#ffffff"
android:textSize="15sp"
android:background="#ff00ff"
style="@style/TextViewStyle" />
</LinearLayout></span>
styles.xml
<span style="font-size:14px;"> <style name="TextViewStyle">
<item name="android:textColor">@android:color/holo_blue_dark</item>
<item name="android:textSize">30sp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:gravity">center_horizontal</item>
</style></span>
activity_main.xml
<span style="font-size:14px;"><LinearLayout
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"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world!" />
<TextView
style="@style/TextViewStyle"
android:text="TV1" />
<TextView
style="@style/TextViewStyle"
android:text="TV2" />
<TextView
android:text="TV1"
android:textColor="#ffffff"
android:textSize="15sp"
android:background="#ff00ff"
style="@style/TextViewStyle" />
</LinearLayout></span>
相关文章推荐
- android图片保存
- 第4章 Android dex文件格式 第一节
- Android代码内存优化建议-Android资源篇
- Android照片墙完整版,完美结合LruCache和DiskLruCache
- 60条Android日常开发总结的技术经验
- Android 版本号 与 API Level 版本 对应表
- 5.4 Android 的上下文菜单: Context Menu,registerForContextMenu(getListView())
- android view组件中一些属性的疑问
- Fragment栈回退和传参方式
- Android简单实现画图功能
- Android studio使用基础
- Android中的Binder机制的简要理解
- Android EventBus 3.0 框架
- Android 命名规范 (提高代码可以读性)
- 解决Android Studio中调试总出现waiting for adb问题
- Android客户端性能优化
- Android轻松画出触摸轨迹
- 使用android studio过程中遇到的异常
- android动态换肤系列4——从apk文件中获取Resources对象(下)
- Android中自定义水平进度条样式之黑色虚线