问题:颜色显示不正确-为什么会这样?

时间:2018-12-08 17:36:17

标签: android xml

我尝试将文本视图之间的视图组设置为它们之间的边界,但是视图的背景色在每个视图中的显示方式有所不同。图像是:

enter image description here

我的activity_main.xml的代码如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="82"
    android:background="@color/view">

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/view"
        android:layout_weight=".4"/>


    <TextView
        android:id="@+id/numbers"
        style="@style/CategoryStyle"
        android:background="@color/category_numbers"
        android:text="@string/category_numbers"
        android:textSize="30sp"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".4"
        android:background="@color/view" />

    <TextView
        android:id="@+id/family"
        style="@style/CategoryStyle"
        android:background="@color/category_family"
        android:text="@string/category_family"
        android:textSize="30sp"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/view"
        android:layout_weight=".4"/>

    <TextView
        android:id="@+id/colors"
        style="@style/CategoryStyle"
        android:background="@color/category_colors"
        android:text="@string/category_colors"
        android:textSize="30sp" />
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/view"
        android:layout_weight=".4"/>

    <TextView
        android:id="@+id/phrases"
        style="@style/CategoryStyle"
        android:background="@color/category_phrases"
        android:text="@string/category_phrases"
        android:textSize="30sp" />
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/view"
        android:layout_weight=".4"/>

</LinearLayout>

colors.xml中的颜色代码为:

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <!-- Primary color of the app (shown in the app bar) -->
    <color name="primary_color">#000000</color>

    <!-- Primary dark color of the app (shown in the status bar) -->
    <color name="primary_dark_color">#000000</color>

    <!-- Background color for app -->
    <color name="tan_background">#FFECB3</color>

    <!-- Background color for the numbers category -->
    <color name="category_numbers">#B00020</color>

    <!-- Background color for the family members category -->
    <color name="category_family">#0336FF</color>

    <!-- Background color for the colors category -->
    <color name="category_colors">#6200EA</color>

    <!-- Background color for the phrases category -->
    <color name="category_phrases">#1B5E20</color>

    <color name="view">#FFEA00</color>
</resources>

似乎textviews的背景色正在影响view的背景色。需要有关此类错误的帮助。

0 个答案:

没有答案