【问题标题】:two dividers in navigation drawer导航抽屉中的两个分隔线
【发布时间】:2014-07-27 20:05:18
【问题描述】:

screenshot of drawer 我的应用程序中有一个 android 导航抽屉。一切正常,但是当我的抽屉可见时,它在项目之间有两条分隔线。 一个是红色的(我想是我做的),另一个是白色的(我不知道它是从哪里来的)

这是我的两个抽屉文件

custom_drawer_item.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="horizontal" >

<LinearLayout 
    android:id="@+id/itemlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
     android:orientation="vertical" 
     android:layout_marginTop="0dp"
      android:background="?android:attr/activatedBackgroundIndicator"

    >
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:minHeight="60dp"

       >

        <ImageView
            android:id="@+id/drawer_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:paddingRight="6dp"
             android:paddingTop="10dp"
            />

        <TextView
            android:id="@+id/drawer_itemName"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textAppearance="?android:attr/textAppearanceLarge"
                  android:textSelectHandleLeft="@+id/drawer_icon"
                  android:textColor="#ffffff"

                  android:paddingTop="10dp"
                         />
      </LinearLayout>

     <View
  android:layout_width="match_parent"
  android:layout_height="1dp"
  android:layout_marginBottom="1dp"
  android:layout_marginTop="1dp"
  android:layout_marginLeft="10dp"
  android:layout_marginRight="10dp"
  android:background="#DADADC"

   ></View>

</LinearLayout>



</LinearLayout>

activity_main.xml

<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">



<FrameLayout 
     android:id="@+id/content_frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

</FrameLayout>

 <ListView
            android:id="@+id/leftdrawer"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="#B80000"
    android:dividerHeight="1dp"
    android:background="#076672"

    />

</android.support.v4.widget.DrawerLayout>

如果您仍然无法获得它,请向我索要 image.il 节目 提前谢谢

【问题讨论】:

标签: android navigation-drawer


【解决方案1】:

这是因为您有这样的View

<View
   android:layout_width="match_parent"
   android:layout_height="1dp"
   android:layout_marginBottom="1dp"
   android:layout_marginTop="1dp"
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp"
   android:background="#DADADC">
</View>

custom_drawer_item.xml 布局的底部。

【讨论】:

  • 谢谢它的工作!但它在做什么呢?
  • @Farhanpatel 这很简单。 Yoh 在列表视图中有一个分隔线,此代码为红色:android:divider="#B80000" 在您的activity_main.xml 中,并有一个高度为 1dp 的View,其值几乎为白色。然后 listview 从custom_drawer_item.xml 加载每一行。所以你看到了两个分隔线。
【解决方案2】:

我认为这两条分隔线之一是 ListView 的分隔线,另一条是您在 custom_drawer_item.xml 中添加的视图,其高度为 1dp。
不需要的可以去掉。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    相关资源
    最近更新 更多