【问题标题】:NavigationDrawer Listview text is white in android 4.2.2NavigationDrawer Listview 文本在 android 4.2.2 中是白色的
【发布时间】:2015-01-30 10:48:55
【问题描述】:

我有一个问题。我创建了列表视图,它将成为 navigationDrawer 中的幻灯片。我可以在 Android 2.X 和 5.X 中看到很好的文本,但在 4.2.2 中文本是不可见的。 这是代码:

<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    <!-- Listview to display slider menu -->
    <ListView
            android:id="@+id/listDrawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:cacheColorHint="@color/nliveo_white"
            android:choiceMode="singleChoice"
            android:divider="@color/nliveo_transparent"
            android:background="@color/nliveo_white"
            android:dividerHeight="0dp"/>
</android.support.v4.widget.DrawerLayout>

以及商品代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              tools:ignore="MissingPrefix">

    <RelativeLayout
            android:id="@+id/layoutDados"
            android:layout_width="match_parent"
            android:layout_height="48dp">

        <ImageView
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:id="@+id/rowIcon"
                android:layout_marginStart="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_centerVertical="true"
                android:contentDescription="descc" />

        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/rowTitle"
                android:layout_centerVertical="true"
                android:layout_marginStart="16dp"
                android:layout_marginLeft="16dp"
                android:layout_toRightOf="@+id/rowIcon"
                android:layout_toEndOf="@+id/rowIcon"
                android:textSize="14sp"
                android:textDirection="anyRtl"
                android:textColor="#000"
                android:layout_marginRight="8dp"
                android:layout_marginEnd="8dp"/>
    </RelativeLayout>
</LinearLayout>

我做错了什么?

【问题讨论】:

  • 尝试从您的 ListView 布局中删除这一行 android:cacheColorHint="@color/nliveo_white"
  • @Govtart 还是不行
  • 尝试 #ff000000 而不是 #000
  • 不工作,我不知道这是在做什么

标签: java android android-listview navigation-drawer


【解决方案1】:

尝试编辑您的ListView

<ListView
        android:id="@+id/listDrawer"
        android:cacheColorHint="@andorid:color/transparent" 
        ... /> <!-- change cacheColorHint to transparent -->

同时编辑你的textColor:

<TextView android:id="@+id/rowTitle"
    android:textColor="#000000"
    ... /> <!-- please have 6 digits HEX code to define the color type -->

注意:颜色有HEX码来定义颜色类型,红、绿、蓝、黑等。HEX码有6位数字,由数字和aplhabet或字母组合而成(从 a 到 e)。例如:#1eff00 HEX 代码的颜色为绿色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    相关资源
    最近更新 更多