文本不会出现在TextView中

问题描述 投票:0回答:1

我正在Android应用中制作导航抽屉。导航抽屉有一个标题,其中包括帐户图标和文本视图。但是当我运行App时,我再也看不到Icon或TextView了。

这就是我得到的,

enter image description here

这是我的导航抽屉activity_admin.xml的代码

<?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout 
        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="com.example.vishistvarugeese.ongc_app.AdminActivity">

        <android.support.design.widget.NavigationView
            app:headerLayout="@layout/admin_nav_header" 
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:background="@color/white"
            app:itemIconTint="@color/black"
            app:itemTextColor="@color/colorAccent"
            app:menu="@menu/admin_menu"
            android:layout_gravity="start"
            app:theme="@style/menu_style">

        </android.support.design.widget.NavigationView>

这是我的导航标题admin_nav_header.xml的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:background="@drawable/headernav"
    android:paddingTop="20dp"
    android:paddingLeft="20dp"
    android:paddingRight="20dp">

    <ImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/ic_account_circle_white_48dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/navUserName"
        android:text="@string/name"
        android:textStyle="bold"
        android:textColor="@color/white"
        android:layout_marginTop="10dp"/>

</LinearLayout>

这就是我想要做的

enter image description here

有人可以帮我解决这个问题吗?

android xml user-interface
1个回答
0
投票

从NavigationView中删除主题和其他属性。

<android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/homeDrawerColor"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/admin_nav_header"
        app:menu="@menu/admin_menu" />

如果没有工作,那么给一个直接的字符串来检查string.xml中的任何问题......

© www.soinside.com 2019 - 2024. All rights reserved.