android - Navigation Drawer RTL lang -
i'm using navigation drawer in 1 of app activity it's open left right how can change right left , icon direction try layout_gravity:right; force closed happened during running app did not answer other question app minimum sdk set 15
here activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:opendrawer="start" > > <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <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:fitssystemwindows="true" app:headerlayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> </android.support.v4.widget.drawerlayout>
and main activity
package ir.diamonddesign.tajrobi96; import android.content.intent; import android.net.uri; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.util.log; import android.view.gravity; import android.view.view; import android.support.design.widget.navigationview; import android.support.v4.view.gravitycompat; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.toast; public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); actionbardrawertoggle toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.navigation_drawer_open, r.string.navigation_drawer_close); drawer.setdrawerlistener(toggle); toggle.syncstate(); navigationview navigationview = (navigationview) findviewbyid(r.id.nav_view); navigationview.setnavigationitemselectedlistener(this); navigationview.setitemicontintlist(null); } @override public void onbackpressed() { drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); if (drawer.isdraweropen(gravitycompat.start)) { drawer.closedrawer(gravitycompat.start); } else { super.onbackpressed(); } } @suppresswarnings("statementwithemptybody") @override public boolean onnavigationitemselected(menuitem item) { // handle navigation view item clicks here. int id = item.getitemid(); if (id == r.id.homeitem) { intent mintent = new intent(this, mainactivity.class); startactivity(mintent); } else if (id == r.id.questionitem) { intent mintent = new intent(this, questionsactivity.class); startactivity(mintent); } else if (id == r.id.answeritem) { } else if (id == r.id.eduitem) { } else if (id == r.id.sourceitem) { } else if (id == r.id.changeitem) { } else if (id == r.id.videositem) { } else if (id == r.id.newsitem) { } else if (id == r.id.shareitem) { intent sharingintent = new intent(android.content.intent.action_send); sharingintent.settype("text/plain"); string sharebody = "اینو ببین : https://cafebazaar.ir/app/ir.tik.tik/?l=fa"; sharingintent.putextra(android.content.intent.extra_subject, "موضوع پیام"); sharingintent.putextra(android.content.intent.extra_text, sharebody); startactivity(intent.createchooser(sharingintent, "از طریق")); } else if (id == r.id.contactitem) { string[] = {"tajrobi@tinytree.ml"}; intent emailintent = new intent(android.content.intent.action_sendto,uri.fromparts("mailto", "", null)); emailintent.putextra(intent.extra_email, to); emailintent.putextra(intent.extra_subject, "موضوع پیام"); emailintent.putextra(intent.extra_text,"سلام از اپیکیشن کنکور تماس میگیرم...."); startactivity(emailintent); } else if (id == r.id.exititem) { finish(); } drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); drawer.closedrawer(gravitycompat.start); return true; } }
it automatically changed rtl when change locale of application.
Comments
Post a Comment