直播平台搭建,Android 黑白模式切换后 文字颜色设置

直播平台搭建,Android 黑白模式切换后 文字颜色设置

values 包下

attrs.xml

 


<?xml version="1.0" encoding="utf-8"?>
<resources>
   + <attr name="cancle_search" format="color" />
</resources>

themes.xml

 


  <style name="Theme.Testdelete" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
    ...
        <!-- Customize your theme here. -->
      +  <item name="cancle_search">@color/text_search_color</item>
    </style>

colos.xml

 


  <color name="text_search_color">#FF000000</color>

values-night 包下

themes.xml

 


 <!-- Base application theme. -->
    <style name="Theme.Testdelete" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
      ...
        <!-- Customize your theme here. -->
       + <item name="cancle_search">@color/text_search_color</item>
    </style>

colors.xml

 


<color name="text_search_color">#ffffff</color>

使用

 


<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
+        android:textColor="?attr/cancle_search" />
</LinearLayout>

 

以上就是直播平台搭建,Android 黑白模式切换后 文字颜色设置, 更多内容欢迎关注之后的文章

 

posted @ 2022-09-23 14:16  云豹科技-苏凌霄  阅读(128)  评论(0)    收藏  举报