简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上

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" >

[android] 安卓自定义样式和主题的更多相关文章

  1. Android RatingBar 自定义样式

    Android RatingBar 自定义样式 1.先定义Style: <style name="RadingStyle" parent="@android:sty ...

  2. xamarin android checkbox自定义样式

    xamarin android checkbox自定义样式 在drawable文件在新建checkbox_bg.xml文件 <?xml version="1.0" encod ...

  3. android中的样式和主题

    有的时候我们一个页面要用很多个textview,而且这些textview的样式非常相像,这种情况下我们可以把这些样式抽取出来,然后在每个textview中引用即可,这样修改起来也方便. 我们来看一个简 ...

  4. Android中自定义样式与View的构造函数中的第三个参数defStyle的意义

    零.序 一.自定义Style 二.在XML中为属性声明属性值 1. 在layout中定义属性 2. 设置Style 3. 通过Theme指定 三.在运行时获取属性值 1. View的第三个构造函数的第 ...

  5. Android下Notification,样式style,主题theme的功能实现

    一:Notification 1.NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVIC ...

  6. Android EditText自定义样式

    第一步:为了更好的比较,准备两个一模一样的EditText(当Activity启动时,焦点会在第一个EditText上,如果你不希望这样只需要写一个高度和宽带为0的EditText即可避免,这里就不这 ...

  7. android中的样式主题和国际化

    一.Android中的样式和主题     1.1样式     样式是作用在控件上的,它是一个包含一个或者多个view控件属性的集合.android style类似网页设计中的css设计思路,可以让设计 ...

  8. Android指南 - 样式和主题

    本文翻译自:https://developer.android.com/guide/topics/ui/themes.html Style和theme词汇是专用术语,下文直接使用而不翻译. 样式和主题 ...

  9. 安卓—自定义 AlertDialog 的样式

    自定义修改安卓弹出框的样式 效果图: 1.在style.xml下添加 <!-- 自定义弹出样式 --> <style name="MyDialogStyle" p ...

随机推荐

  1. js计算机样式window.getComputedStyle(ele,null)与

    一.getComputedStyle兼容IE8以上,范户籍的计算样式的值都是绝对值,没有相对单位(如:width:10em; 它打印出来是160px) window.getComputedStyle( ...

  2. luoguP3359 改造异或树

    https://www.luogu.org/problemnew/show/P3359 因为 a ^ b ^ b = a,所以我们预处理 1 到所有点的距离,将删边的操作反过来变成加边,对于每一个联通 ...

  3. sed--行编辑器命令

    2017-11-02 sed:行编辑器,按行处理:默认不做原文件修改,会在sed自身的模式空间中按行读相关的数据并完成编辑,然后显示到屏幕上     一.     基本用法: 1. 语法格式: sed ...

  4. 除了ROS, 机器人定位导航还有其他方案吗?

    利用ROS进行机器人开发,我想大多数企业是想借助ROS实现机器人的导航.定位与路径规划,它的出现大大降低了机器人领域的开发门槛,开发者无需向前人一样走众多弯路,掌握多种知识才能开始实现机器人设计的梦想 ...

  5. Android Fragment之间的通信(用fragment替换掉XML布局文件中的一个线性布局)

    1.XML布局 (1)主界面 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...

  6. 128th LeetCode Weekly Contest Capacity To Ship Packages Within D Days

    A conveyor belt has packages that must be shipped from one port to another within D days. The i-th p ...

  7. 4KM

    ip addr add 10.9.8.100/24 broadcast + dev eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 ifdown eth0 ...

  8. Owin WebAPI上传文件

    Owin是微软出了几年的东东了,一直没时间学习.大概了解了下,是一个脱离IIS环境,快速搭建WebAPI服务的东西. 刚好想尝试下尽量脱离IIS创建简单快捷配置的项目,就是用了Nginx+Owin的模 ...

  9. python2.x提示这个错误:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position

    查了好久下面这个方法可用: 发现应该是因为python2.x的默认编码是ascii,而代码中可能由utf-8的字符导致,解决方法是设置utf-8. 找到出错的文件,在import后增加下面几行: #! ...

  10. 初学SSM遇到的BUG

    一.SpringMVC部分 1.参数绑定 1.1简单类型绑定 参数类型推荐使用包装数据类型,因为基础数据类型不可以为null 整形:Integer.int 字符串:String 单精度:Float.f ...