Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:如何在另一个布局的XML中使用样式中的颜色_Android_Xml_Android Layout_Android Theme - Fatal编程技术网

Android:如何在另一个布局的XML中使用样式中的颜色

Android:如何在另一个布局的XML中使用样式中的颜色,android,xml,android-layout,android-theme,Android,Xml,Android Layout,Android Theme,我在XML中得到了这种风格: <resources> <!-- Base application theme. --> <style name="AppTheme" parent="AppTheme.Base"/> <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your t

我在XML中得到了这种风格:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->

        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/teal_500</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/teal_700</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/light_blue_500</item>

        <!-- needed to suppress the old ActionBar when using the new Toolbar -->
        <item name="android:windowActionBar">false</item>

        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight & colorSwitchThumbNormal. -->
    </style>

</resources>
你可以这样用

<TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/text_input"
              android:textColor="?attr/colorPrimary"   
              android:fontFamily="sans-serif-bold"
              android:text="some text"
              android:textSize="24dp"/>

Alhamdulillah,jajakumullah,你救了我两天!
<TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/text_input"
              android:textColor="?attr/colorPrimary"   
              android:fontFamily="sans-serif-bold"
              android:text="some text"
              android:textSize="24dp"/>