2

enter image description here

How to adjust this ? I am trying to make a navigation drawer in my app,I managed to add horizontal lines between items, but I want to adjust space between the icon and the title.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Abhishek Sengupta
  • 2,938
  • 1
  • 28
  • 35

3 Answers3

0

The best approach is to use a RecyclerView inside NavigationDrawer. You can always customize a recyclerView item (i.e. providing gaps between different elements).

0

another way to implement this,, use navigation bar like this

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        app:headerLayout="@layout/drawer_header"
        android:background="#00fdfdfd"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white">
<LinearLayout
    android:animateLayoutChanges="true"
    android:layout_marginTop="45dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/pull_navBar"
        android:layout_width="35dp"
        android:layout_height="match_parent">
        <ImageView
            android:layout_marginTop="105dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_double_arrow_left"/>
    </LinearLayout>
<LinearLayout
    android:background="@color/grey"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:padding="2dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="2">
        <TextView
            android:textColor="@android:color/holo_blue_light"
            android:text="Date"
            android:textSize="16dp"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />
        <TextView
            android:textColor="@android:color/holo_blue_light"
            android:text="Session Name"
            android:layout_weight="1"
            android:textSize="16dp"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />
    </LinearLayout>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/rec_sessionList"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"/>
</LinearLayout>
</LinearLayout>
    </android.support.design.widget.NavigationView>

you can put any root layout inside the navigation and achive any view

ankur uniyal
  • 86
  • 11
0

Add this code in style.xml

<style name="NavStyle" parent="Base.TextAppearance.AppCompat">
    <item name="android:textSize">14sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">@color/candidate_title</item>
    <item name="android:padding">0dip</item>
</style>

and set app:itemIconPadding="@dimen/activity_margin_10dp" app:itemTextAppearance="@style/NavStyle"in NavigationView

sushant singh
  • 696
  • 1
  • 8
  • 18