Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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导航抽屉自定义项目未注册_Android_Xml_Alignment_Navigation Drawer - Fatal编程技术网

Android导航抽屉自定义项目未注册

Android导航抽屉自定义项目未注册,android,xml,alignment,navigation-drawer,Android,Xml,Alignment,Navigation Drawer,我有一个带有自定义项目的导航抽屉。每个项目都有一个TextView和一个微调器。在inspector中,一切看起来都很好,但在运行时,没有任何东西是对齐的。有什么想法吗 在电话里看起来像这样 这是我的密码 项目菜单 <?xml version="1.0" encoding="utf-8"?> 这是一个项目的代码(所有项目都遵循相同的结构) 为您的导航视图项目尝试以下操作: 您必须为布局权重添加android:layout\u width=“0dp”,才能正常工作

我有一个带有自定义项目的导航抽屉。每个项目都有一个TextView和一个微调器。在inspector中,一切看起来都很好,但在运行时,没有任何东西是对齐的。有什么想法吗

在电话里看起来像这样

这是我的密码

项目菜单

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


这是一个项目的代码(所有项目都遵循相同的结构)


为您的导航视图项目尝试以下操作:

您必须为
布局权重添加
android:layout\u width=“0dp”
,才能正常工作

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_cost"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:weightSum="2">

    <TextView
        android:id="@+id/txt_cost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="right"
        android:layout_weight="1"
        android:text="Coste:"
        android:textColor="@color/color_black"
        android:textSize="15sp" />

    <Spinner
        android:id="@+id/spn_cost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

尝试对齐属性将其设置为左侧或其他位置
<?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="wrap_content"
    android:orientation="horizontal"
    android:weightSum="2"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:id="@+id/rl_cost">

    <TextView
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Coste:"
        android:textSize="15sp"
        android:id="@+id/txt_cost"
        android:textColor="@color/colorBlack" />

    <Spinner
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/spn_cost"/>

</LinearLayout>
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_cost"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:weightSum="2">

    <TextView
        android:id="@+id/txt_cost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="right"
        android:layout_weight="1"
        android:text="Coste:"
        android:textColor="@color/color_black"
        android:textSize="15sp" />

    <Spinner
        android:id="@+id/spn_cost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>