2016-09-13 7 views
0

私は自分のアプリのアクティビティの1つで左から右に向かって右から左に、アイコンの向きを変える方法を使用しています 私はlayout_gravityを試しています。しかし、力は、私が15ここナビゲーションドロワRTL lang

に設定されている他の質問 アプリ最小SDKから私の答えを取得していないアプリ を実行している間に起こっ閉じ

<?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> 

activity_main.XML

であり、これは主な活動

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[] TO = {"[email protected]"}; 

      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; 
    } 
} 
です
+0

@MikeM。いいえ私はminSdkVersion 15を使っていますか? –

答えて

0

アプリケーションのロケールを変更すると、自動的にRTLに変更されます。