I use a Toolbar in which I wanted to be transparent, until I did however the button burger n is clickable, can anyone help?
Myxml:
<?xmlversion="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
</RelativeLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
My code:
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
ActionBarDrawerToggle toggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.parseColor("#ffffff"));
toolbar.setBackgroundColor(Color.TRANSPARENT);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
Window window = this.getWindow();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(Color.TRANSPARENT);
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.frame_Layout, new Fragment_Inicio());
fragmentTransaction.disallowAddToBackStack();
fragmentTransaction.commit();
NavigationView navigationView = findViewById(R.id.nav_view_inthebox);
navigationView.setNavigationItemSelectedListener(this);
Helper h = new Helper();
ImageButton callflex = findViewById(R.id.nav_logo);
h.Abrir_link_externo_botao(callflex,"https://www.callflex.com.br", this);
ImageButton linkedin = findViewById(R.id.nav_linkedin);
h.Abrir_link_externo_botao(linkedin,"https://www.linkedin.com/company-beta/949222/", this);
ImageButton instagram = findViewById(R.id.nav_instagram);
h.Abrir_link_externo_botao(instagram,"https://www.instagram.com/callflexbr/", this);
ImageButton facebook = findViewById(R.id.nav_facebook);
h.Abrir_link_externo_botao(facebook,"https://www.facebook.com/callflex/", this);
ImageButton youtube = findViewById(R.id.nav_youtube);
h.Abrir_link_externo_botao(youtube,"https://www.youtube.com/channel/UCyMBD5Pcu6nHUlDij_N-iRw", this);
}
public void setActionBarTitle(String title) {
getSupportActionBar().setTitle(title);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}else {
super.onBackPressed();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (toggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}