How to set Navigation Drawer icons to the right side of the Item Texts?

后端 未结 4 822
旧时难觅i
旧时难觅i 2021-01-24 05:33

My Project Screenshot: My Project

My Target Design: My Target

I have created a (right to left) navigation drawer. It\'s working fine but when I\'m trying to move

4条回答
  •  情书的邮戳
    2021-01-24 06:05

    use this open your Navigation drawer right side if your target API is 17+

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
          getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
      }
    

    Try this Create a new Layout like below

     
    

    than set Custom view to Your navigation view using below code

     YourNavigationView.getMenu().getItem(0).setActionView(R.layout.custom_layout);
    

    setActionView(int resId)

    Set an action view for this menu item.

    EDIT

    try this to modify your single navigation menu item

    TextView  textView = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
    textView.setText("ONE");
    textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_favourite, 0, 0);
    textView.setTextColor(ContextCompat.getColor(this,R.color.colorPrimary));
    navigationView.getMenu().getItem(0).setActionView(textView);
    

提交回复
热议问题