Android 9.0中的暗黑主题使我的应用程序布局变得丑陋

5

我只是在设计我的布局时没有预料到任何问题,但有一天安卓9.0推出了,我买了手机并在其中安装了我的应用程序,并尝试打开我的应用程序并将其设置为夜间模式,开始看到白色布局在黑暗中发生变化,我的思维变得混乱。我想知道如何禁用主题。

I tried changing themes, changing the background colors none of those works

<RelativeLayout
        android:layout_width="190dp"
        android:layout_height="200dp"
        android:layout_marginTop="-15dp"
        android:layout_below="@+id/tableTxt"
        android:background="@drawable/table_no_orders_border"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        android:layout_centerHorizontal="true">

    <android.support.v7.widget.CardView
            android:id="@+id/cv_one_login"
            android:layout_width="189dp"
            android:layout_height="199dp"
            android:layout_centerHorizontal="true"
            android:elevation="10dp"
            app:cardCornerRadius="1dp"
            app:cardElevation="10dp"
            android:layout_marginTop="0.1dp">

            <android.support.v4.widget.NestedScrollView
                    android:id="@+id/sv1"
                    android:layout_width="match_parent"
                    android:layout_height="147dp"
                    android:scrollbars="vertical"
                    android:scrollbarSize="10dp"
                    android:isScrollContainer="true">
                <TextView
                        android:id="@+id/tableItems"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="@string/table"
                        android:layout_marginStart="5dp"
                        android:layout_marginTop="13dp"
                        android:textColor="@color/TextcolorforBlack"/>
            </android.support.v4.widget.NestedScrollView>
            <TextView
                    android:id="@+id/totalTableBill"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="@string/total_bill"
                    android:textColor="@color/SettingsColor"
                    android:layout_below="@id/sv1"
                    android:textAlignment="gravity"
                    android:gravity="bottom"
                    android:layout_marginStart="5dp"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>

我希望我的布局保持设计原样,即使应用了主题也应该如此。

enter image description here

1个回答

2
你可以在应用程序清单文件中更改应用主题,例如:Original Answer。请注意不要删除html标签。
<application 
    android:theme="@android:style/Theme.Holo"/>

<application 
    android:theme="@android:style/Theme.Holo.Light"/>

<application 
    android:theme="@android:style/Theme.Black"/>

<application 
    android:theme="@android:style/Theme.DeviceDefault"/>

或者您可以在styles.xml文件中自定义主题,然后在清单中应用。"应用"即可。请注意保留html标记。
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"/>
<style name="AppTheme" parent="AppBaseTheme"/>

"最初的回答" 变成 "原始答案"
现在在清单文件中。
<application 
    android:theme="@style/AppBaseTheme"/>

你可以在Android Studio的预览窗口中预览主题。

输入图像描述

最初的回答已翻译。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接