当前位置: 动力学知识库 > 问答 > 编程问答 >

android - How can I add a horizontal line between certain elements in the navigation drawer

问题描述:

How can I add horizontal line below certain elements in the navigation drawer.

For example if my navigation drawer has the following elements; Home, Start, Break, Learn, Walk , Bike, Dog, Cat.

If I want to place a horizontal line below "Break", and another horizontal line below "Bike" and "Cat" how can I do that.

Is there a tutorial on how to do this or website I can be referred to.

网友答案:

Seems you are using ListView/GridView in your navigation drawer. You can use divider property put a divider.

<ListView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/cashItemsList"
 android:cacheColorHint="#00000000"
 android:divider="@drawable/list_divider"></ListView>

xml for list_divider should be somewhat like this

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke
        android:height="1dp"
        android:color="#00000000"
        android:dashWidth="1dp"
        android:dashGap="1dp" />
</shape>
网友答案:

Inside each view, you can add a layout with this parameters:

android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF000000"

Other: You can create a new view and call it like UnderlineTextView (inherit from TextView) and in draw method set that this view draw a line at bottom.

分享给朋友:
您可能感兴趣的文章:
随机阅读: