zoukankan      html  css  js  c++  java
  • 样式styles和主题theme

    参考资料: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>

  • 相关阅读:
    Mysql数据库分库备份,分表备份
    KICKSTART无人值守安装
    git的使用
    iowait 过高问题的查找及解决linux
    Redis配置文件redis.conf详解
    安装和使用ZFS
    GlusterFS配置及使用
    Ceph与Gluster之开源存储的对比
    去掉Tomcat的管理页面
    Tomcat不加项目名称访问设置
  • 原文地址:https://www.cnblogs.com/maogefff/p/7799345.html
Copyright © 2011-2022 走看看