2017-10-11 80 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

感谢但切换动画 –