React Native Navigation Drawer overlap status bar

Home / Uncategorized / React Native Navigation Drawer overlap status bar

Question:
The React Navigation Drawer overlaps with the Android status bar. Is there a way to prevent that? Source here
contentOptions: {
style: {
marginTop: 24,
},
},

This only gives margin to the content, not the whole drawer.


Answer:
Try this hope it was helpful for you

1.Make "Header layout" in which, what you want to like image and text. enter image description here(prepare a custom menu-drawer)



Then make another layout for drawer-menu. This is Parent_main










Make Class For navigation Adapter

public class NavigationDrawerAdapter extends
RecyclerView.Adapter {
private LayoutInflater inflater;
private List> focusHeader;
private Context context;
public static boolean
Snackbar snackbar;
String[] name={
"About Focus",
"FAQ",
"Help"};
Integer[] image_ID={
R.drawable.logo,
R.drawable.faq,
R.drawable.help,};
Intent intent;
public NavigationDrawerAdapter(List>
focusHeader,Context context) {
this.focusHeader=focusHeader;
this.context = context;
inflater = LayoutInflater.from(context);}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.nav_drawer_row, parent, false);
MyViewHolder holder = new MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
holder.tv_subTitle.setText(name[position]);
holder.iv_drawerIcon.setImageResource(image_ID[position]);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

else if (name[position].equals("About Focus")){

}
else if (name[position].equals("FAQ")){

}
else if (name[position].equals("Help")){

}

});
}

@Override
public int getItemCount() {
return name.length;
}

class MyViewHolder extends RecyclerView.ViewHolder {
TextView tv_title,tv_subTitle;
ImageView iv_drawerIcon;

public MyViewHolder(View itemView) {
super(itemView);
iv_drawerIcon=itemView.findViewById(R.id.iv_drawerIcon);
tv_subTitle=itemView.findViewById(R.id.tv_subTitle);
}
}

Make a layout for nav_drawer_row



Use this Class AS Parent_main

public class TabActivityClass extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.parent_main);
RecyclerView.LayoutManager mLayoutManager = new
LinearLayoutManager(getApplicationContext());
rv_navigation.setLayoutManager(mLayoutManager);
rv_navigation.setItemAnimator(new DefaultItemAnimator());
rv_navigation.setAdapter(new NavigationDrawerAdapter(new
ArrayList>(),parent_main.this));
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.addDrawerListener(toggle);
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
}
}
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *