2

i am making a design attach in the link for navigation drawer which consist of a hover above the menu item but its width is greater than navigation palette.

the design for hover effect

![enter image description here

Edit : the hover is the white background box over history. its should be like this when selected.

xml

<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="@drawable/background_slider"
    android:fitsSystemWindows="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="20dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/nav_item_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>


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

Java

RecyclerView recycler = findViewById(R.id.nav_item_list);
    LinearLayoutManager layout = new LinearLayoutManager(this);
    recycler.setLayoutManager(layout);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recycler.getContext(),
            layout.getOrientation());
    dividerItemDecoration.setDrawable(ContextCompat.getDrawable(this, R.drawable.item_divider));
    recycler.addItemDecoration(dividerItemDecoration);

    String[] englishTitles = getResources().getStringArray(R.array.nav_english_items);
    String[] urduTitles = getResources().getStringArray(R.array.nav_urdu_items);
    int[] icons = new int[englishTitles.length];
    TypedArray navIcons = getResources().obtainTypedArray(R.array.nav_icons);
    try {
        for (int i = 0; i < icons.length; i++) {
            icons[i] = navIcons.getResourceId(i, -1);
        }
    } finally {
        navIcons.recycle();
    }
    recycler.setAdapter(new NavigationItemAdapter(this, englishTitles, urduTitles, icons, this));

P.S.: i have tried the following as well.

Change the color of a checked menu item in a navigation drawer

Android navigation drawer, change text/hover color

i really need to make this as soon as possible.
thanks in advance let me know if anything is missing!

Atif Afridi
  • 133
  • 1
  • 10

0 Answers0