参考资料:http://blog.csdn.net/sshhbb/article/details/7219838/

/values/styles.xml

<resources>

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> //这个是主题,继承与DarkActionBar
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="buttonstyle"> //这个为自己添加的
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:text">heihei</item>
</style> </resources>

/layout/Activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="sample.android_serialport_api.myapplication.MainActivity">
  ...
<Button
style="@style/buttonstyle" //在这里使用的style
android:id="@+id/butto6"/>
<Button
style="@style/buttonstyle"
android:id="@+id/butto7"/>
<Button
style="@style/buttonstyle"
android:id="@+id/butto8"/>
</LinearLayout>

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sample.android_serialport_api.myapplication"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"> //在这里使用的主题
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application> </manifest>

样式styles和主题theme的更多相关文章

  1. 第十四章:样式(Style)和主题(Theme)

    简介 Android的样式(Style)和主题(Theme)文件就好比WEB开发中的CSS一样,可以实现UI界面的风格统一管理,这和Windows平台的XAML格式(Silverlight.WPF)类 ...

  2. Android 自定义属性(attrs)、样式(Style)、主题(Theme)

    Android 自定义属性(attrs).样式(Style).主题(Theme) https://www.cnblogs.com/dandre/p/4507024.html https://blog. ...

  3. Android 样式 (style) 和主题(theme)

    转载:https://gold.xitu.io/post/58441c48c59e0d0056a30bc2 样式和主题 样式是指为 View 或窗口指定外观和格式的属性集合.样式可以指定高度.填充.字 ...

  4. Android样式(style)和主题(theme)

    样式和主题 样式是指为 View 或窗口指定外观和格式的属性集合.样式可以指定高度.填充.字体颜色.字号.背景色等许多属性. 样式是在与指定布局的 XML 不同的 XML 资源中进行定义. Andro ...

  5. 20.(转)Android的样式(Style)和主题(Theme)

    Android上的Style分为了两个方面: 1,Theme是针对窗体级别的,改变窗体样式: 2,Style是针对窗体元素级别的,改变指定控件或者Layout的样式. Android系统的themes ...

  6. android的样式(style)与主题(theme)

    Android上的Style分为了两个方面: 1,Theme是针对窗体级别的,改变窗体样式: 2,Style是针对窗体元素级别的,改变指定控件或者Layout的样式. Android系统的themes ...

  7. 安卓样式Style和主题Theme

    1. 区别 不过style是针对view来说的,比如TextView和EditText这些:而Theme必须针对整个activity或者整个application 2. 样式 创建一个样式,根元素 & ...

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

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

  9. 总结一下Android中主题(Theme)的正确玩法

    在AndroidManifest.xml文件中有<application android:theme="@style/AppTheme">,其中的@style/AppT ...

随机推荐

  1. SignalR支持的平台

    服务器系统要求 SignalR服务器组件可以托管在各种服务器配置上.本节介绍受支持的操作系统版本,.NET框架,Internet Information Server和其他组件. 支持的服务器操作系统 ...

  2. npm 安装less

    npm install less less-loader --save 在style加上lang="less" 就可以直接用了

  3. mysql 判断表字段或索引是否存在 - 举一反三

    判断字段是否存在: DROP PROCEDURE IF EXISTS schema_change; DELIMITER // CREATE PROCEDURE schema_change() BEGI ...

  4. “全栈2019”Java多线程第八章:放弃执行权yield()方法详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java多 ...

  5. 【文文殿下】洛谷P2408 不同子串个数

    题目链接https://www.luogu.org/problemnew/show/P2408 SAM裸题,大力求就行了 #include<cstdio> #include<cstr ...

  6. 《快学Scala》第八章 继承

  7. Elasticsearch(八)【NEST高级客户端--分析器】

    分析 分析是将文本(如任何电子邮件的正文)转换为添加到反向索引中进行搜索的tokens或terms的过程. 分析由analyzer执行,分析器可以是内置分析器或每个索引定义的定制分析器. 书写分析器测 ...

  8. 记一名软件实施自学转Java开发,附学习计划

    2015年毕业到现在已经3年了,而我转型开发已经有一年的时间了.写这篇文章除了记录,主要还是想分享一些经历给想要转型开发的同学们,不要走那些我走过的弯路. 2015年入职了第一家公司,当时是做的分销系 ...

  9. IDEA 引入外部jar包 pom 配置,防止打包失败

    1. <!--添加外部依赖-->        <dependency>            <groupId>Ice</groupId>       ...

  10. php pdo prepare真的安全吗

    详见 这里 Let's say I have code like this: $dbh = new PDO("blahblah"); $stmt = $dbh->prepar ...