简单练习自定义样式和主题,样式是加在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. 使用adb工具调试出现error:device offline

    使用adb工具调试设备的时候会出现error:device offline,网上找了很多办法,最后终于解决了. 如果你也遇到这样的问题,先试试简单的办法,不行的话,试试这个..<.< ad ...

  2. 百度联盟广告 http://cpro.baidustatic.com/cpro/ui/c.js

    <script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript" ...

  3. ListView ,GridView 通用适配器

    前言 接近半年的时间没有写博客了,今年公司的项目有点多,比较忙,没时间写,这是其一.其次是,这半年来,有时间的时候,我都会看看自己以前写的博客,也许是以前刚刚写博客,经验不足,感觉写出来的博客质量很不 ...

  4. jxl读取excel

    String path=""; String path2=""; File file = new File(path); File file2 = new Fi ...

  5. svn命令行的使用

    只是说一下,svn平时工作时常用的命令 1.svn delete 目录 删除svn版本里的相关目录 2.svn add 目录 将本地的目录添加到svn版本信息里 3.svn commit 目录 提交s ...

  6. P5108 仰望半月的夜空 SAM+线段树覆盖

    $ \color{#0066ff}{ 题目描述 }$ 半月的夜空中,寄托了多少人与人之间的思念啊 曦月知道,这些思念会汇集成一个字符串\(S(n = |S|)\) 由于思念汇集的过于复杂,因此曦月希望 ...

  7. todocmvc的安装

    安装依赖 官网 安装依赖的css,js $npm install 引入vue <script src="js/vue.js"></script> 定义初始化 ...

  8. 阿里云服务主机部署Thinkphp系统错误解决方案

    最近在阿里云上购买了虚拟主机,于是有了把自己的网站挂在云上的冲动,那就行动呗.本来想的很简单,以为在修改数据库配置之后,将文件打包上传,然后就可以了,可在实际操作过程中,出现了很多问题,找了很多资料, ...

  9. Sql2008R2 日志无法收缩解决方案

    在网上查了二天资料,终于找到个解决了这个问题的方案,记录下来.方便下次处理.    解决方案转贴自:  https://blog.csdn.net/kk185800961/article/detail ...

  10. GIF图制作

    一.安装image 首先在cmd中敲入代码pip install imageio,以便制作动图 二.安装完之后便可读取gif了 在idle中输入代码 import imageio savename = ...