android简单的样式和主题

android的样式:

在xml文件中定义Textview的样式:

<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
       style="@style/text_content_style"
       android:text="你好啊"
        />
     <TextView
         style="@style/text_content_style"
       android:text="你好啊"
        />
      <TextView
         style="@style/text_content_style"
       android:text="你好啊"
        /> 
        <TextView
          style="@style/text_content_style"
       android:text="你好啊"
        />

</LinearLayout>

 android中style文件写在res/values/styles.xml中:

 <style name="text_content_style">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textSize">25sp</item>
        <item name="android:textColor">#00ff00</item>
    </style>

android的主题:

 android中style文件写在res/values/styles.xml中:

<style name="app_theme">
        <item name="android:background">#0000ff</item>
    </style>

作用在的Manifest中的Activity中和Application中:

<application
         android:theme="@style/app_theme"
        android:allowBackup="true"
        android:label="@string/app_name"
         >
        <activity
            android:theme="@style/app_theme"
            android:name="com.example.styletheme.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
原文地址:https://www.cnblogs.com/childhooding/p/4347324.html