2017-10-11 83 views
-2
---------------- 
| <- =   | 
---------------- 

<- back 
= navigation toggle button 

我試着按鈕添加回navihgation抽屜,但我不能添加這樣如何獲得並列導航和後退按鈕側的Android

我希望兩個按鈕simulteneously

+0

您的圖像不顯示 –

+0

請分享您的代碼 –

+0

@NileshRathod https://meta.stackoverflow.com/questions/357690/imgur-returning-503-service-unavailable –

回答

1

試這種使用習慣Toolbar

<android.support.v7.widget.Toolbar 
    android:id="@+id/ar_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/img_back" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/ic_launcher_round" /> 

     <ImageView 
      android:id="@+id/img_drawericon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/ic_launcher_round" /> 

    </LinearLayout> 
</android.support.v7.widget.Toolbar> 

比集點擊收聽到這imageview在你的活動這樣

Toolbar toolbar; 
     toolbar = (Toolbar) findViewById(R.id.ar_toolbar); 
     ImageView backIMG =(ImageView) toolbar.findViewById(R.id.img_back); 
     ImageView drawerIMG =(ImageView) toolbar.findViewById(R.id.img_drawericon); 
     setSupportActionBar(toolbar); 

     backIMG.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Toast.makeText(ReferralsActivity.this, "Back arrow clicked", Toast.LENGTH_SHORT).show(); 
       onBackPressed(); 
      } 
     }); 

     drawerIMG.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Toast.makeText(ReferralsActivity.this, "Drawer icon clicked", Toast.LENGTH_SHORT).show(); 
      } 
     }); 
+0

感謝但切換動畫 –