Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 layout 白色在工具栏中不可见_Android Layout - Fatal编程技术网

Android layout 白色在工具栏中不可见

Android layout 白色在工具栏中不可见,android-layout,Android Layout,我的布局中有一个绿色工具栏,我在其中插入了一个文本视图,使文本水平居中。我希望工具栏的文本为白色,并为此选择白色。然而,白色文本几乎看不见。有人能帮忙吗?我会很感激的 以下是TextView的XML代码: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res

我的布局中有一个绿色工具栏,我在其中插入了一个文本视图,使文本水平居中。我希望工具栏的文本为白色,并为此选择白色。然而,白色文本几乎看不见。有人能帮忙吗?我会很感激的

以下是TextView的XML代码:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:ignore="ExtraText">




    '<!--Learning: The following lines define a toolbar -->'

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_mainActivity"
        android:layout_width="match_parent"
        android:layout_height="53dp"
        android:background="#435cb53f"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:titleTextColor="@android:color/holo_green_light" />


    <Button
        android:id="@+id/Bestellen_Button"
        android:layout_width="255dp"
        android:layout_height="96dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="@string/Bestellen_Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.584"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.461" />

    <Button
        android:id="@+id/Statistik_Button"
        android:layout_width="256dp"
        android:layout_height="95dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="@string/Statistik_Button"
        android:background="@android:color/transparent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.875" />

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="147dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="80dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="80dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@android:color/transparent"
        android:contentDescription="Test"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.744"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.203"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="153dp" />

    <TextView
        android:id="@+id/textView_ToolBar_MainActivity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="TestText"
        android:textColor="@android:color/white"
        android:textSize="24sp"
        android:visibility="visible"
        app:fontFamily="@font/roboto_bold"
        app:layout_constraintBottom_toBottomOf="@+id/toolbar_mainActivity"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.535"
        app:layout_constraintStart_toStartOf="@+id/toolbar_mainActivity"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.421"
        tools:text="TestText" />


</android.support.constraint.ConstraintLayout>

''

问题在于您在工具栏中使用的标高。这意味着,工具栏位于其余部分的“顶部”,因此覆盖在TextView上。这意味着文本并没有按照您希望的方式显示

解决方案1 完全去掉标高,文本将显示为纯白色

解决方案2 我认为,如果您将工具栏和文本视图都放在ConstraintLayout中的另一个布局中(例如,放在相对视图中),并将高程添加到该布局中,而不是工具栏中,也应该可以工作。这样,两个图元应该具有相同的高程,而不会相互投射阴影。但是我不完全确定这个解决方案,你必须试试看它是否有效


是有关高程的一些附加信息。

问题在于您在工具栏中使用的高程。这意味着,工具栏位于其余部分的“顶部”,因此覆盖在TextView上。这意味着文本并没有按照您希望的方式显示

解决方案1 完全去掉标高,文本将显示为纯白色

解决方案2 我认为,如果您将工具栏和文本视图都放在ConstraintLayout中的另一个布局中(例如,放在相对视图中),并将高程添加到该布局中,而不是工具栏中,也应该可以工作。这样,两个图元应该具有相同的高程,而不会相互投射阴影。但是我不完全确定这个解决方案,你必须试试看它是否有效


是一些关于海拔的附加信息。

我觉得发生这种情况的原因是海拔。由于工具栏的标高为4dp,因此它位于textView的上方

我想如果您添加
android:elevation=“4dp”
或任何超过4dp的内容,您将能够清楚地看到文本


祝你好运。

我觉得它发生的原因是海拔升高。由于工具栏的标高为4dp,因此它位于textView的上方

我想如果您添加
android:elevation=“4dp”
或任何超过4dp的内容,您将能够清楚地看到文本


祝你好运。

到底是什么问题?是因为两种颜色的对比度不够高,还是字体太薄?也许你可以添加一个屏幕截图来让你的问题更清楚。我添加了一个来自Android Studio的屏幕截图。在蓝图上,您可以看到文本“TestText”是可见的,但在实际布局上,它几乎不可见,因为我选择白色作为颜色。toolbar\u mainActivity的xml是什么?您在布局文件中的TextView之前还是之后声明了它?toolbar\u mainActivity是主要活动的工具栏。它是在TextView之前定义的。我试图更改顺序,这意味着TextView是在工具栏之后定义的。但这并没有改变任何事情。白色文本仍然几乎看不见。到底是什么问题?是因为两种颜色的对比度不够高,还是字体太薄?也许你可以添加一个屏幕截图来让你的问题更清楚。我添加了一个来自Android Studio的屏幕截图。在蓝图上,您可以看到文本“TestText”是可见的,但在实际布局上,它几乎不可见,因为我选择白色作为颜色。toolbar\u mainActivity的xml是什么?您在布局文件中的TextView之前还是之后声明了它?toolbar\u mainActivity是主要活动的工具栏。它是在TextView之前定义的。我试图更改顺序,这意味着TextView是在工具栏之后定义的。但这并没有改变任何事情。白色文本仍然几乎看不见。