Android 反应本机导航抽屉重叠状态栏
与Android状态栏重叠。有没有办法防止这种情况发生?来源 这只给内容留了空白,而不是整个抽屉。试试这个,希望对你有所帮助。 1.制作“标题布局”,其中,您喜欢的图像和文本。 (准备一个自定义菜单抽屉)Android 反应本机导航抽屉重叠状态栏,android,react-native,react-navigation,Android,React Native,React Navigation,与Android状态栏重叠。有没有办法防止这种情况发生?来源 这只给内容留了空白,而不是整个抽屉。试试这个,希望对你有所帮助。 1.制作“标题布局”,其中,您喜欢的图像和文本。 (准备一个自定义菜单抽屉) 然后为抽屉菜单做另一个布局。这是父级\u主 为导航适配器创建类 公共类NavigationDrawerapter扩展 RecyclerView.适配器{ 私人充气机; 私人名单主持人; 私人语境; 公共静态布尔 斯纳克巴; 字符串[]名称={ “关于焦点”, “常见问题”, “
公共类NavigationDrawerapter扩展
RecyclerView.适配器{
私人充气机;
私人名单主持人;
私人语境;
公共静态布尔
斯纳克巴;
字符串[]名称={
“关于焦点”,
“常见问题”,
“帮助”};
整数[]图像\u ID={
R.drawable.logo,
R.drawable.faq,
R.drawable.help,};
意图;
公共导航抽屉雷达(列表
焦点引导者(上下文){
this.focusHeader=focusHeader;
this.context=上下文;
充气器=从(上下文);}
@凌驾
公共MyViewHolder onCreateViewHolder(视图组父级,int-viewType){
视图=充气机。充气(R.layout.nav\u drawer\u row,parent,false);
MyViewHolder=新的MyViewHolder(视图);
报税表持有人;
}
@凌驾
公共无效onBindViewHolder(MyViewHolder,最终整数位置){
holder.tv_subTitle.setText(姓名[职位]);
持有人iv付款人setImageResource(图像ID[位置]);
holder.itemView.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
else if(name[position].equals(“关于焦点”)){
}
else if(名称[位置].equals(“常见问题”)){
}
else if(name[position].equals(“Help”)){
}
});
}
@凌驾
public int getItemCount(){
返回name.length;
}
类MyViewHolder扩展了RecyclerView.ViewHolder{
text查看电视标题、电视字幕;
ImageView iv_抽屉;
公共MyViewHolder(查看项目视图){
超级(项目视图);
iv_-drawerIcon=itemView.findViewById(R.id.iv_-drawerIcon);
tv\u subTitle=itemView.findviewbyd(R.id.tv\u subTitle);
}
}
公共类TabActivityClass扩展了AppCompatActivity{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.parent_main);
RecyclerView.LayoutManager mLayoutManager=新建
LinearLayoutManager(getApplicationContext());
rv_navigation.setLayoutManager(mLayoutManager);
rv_navigation.setItemAnimator(新的DefaultItemAnimator());
rv_navigation.setAdapter(新导航抽屉雷达)(新
ArrayList(),parent_main.this));
抽屉=(抽屉布局)findViewById(R.id.抽屉布局);
ActionBarDrawerToggle切换=新建ActionBarDrawerToggle(
这个,抽屉,工具栏,R.string.navigation\u抽屉\u open,
R.string.navigation\u drawer\u close);
抽屉。添加抽屉链接器(切换);
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
}
}
在
组件之前添加
怎么样?
别忘了从'react native'导入{StatusBar}它会转到根组件,没有合适的位置放置它
contentOptions: {
style: {
marginTop: 24,
},
},
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_parenthide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="@dimen/_10dp"
android:layout_marginBottom="@dimen/_10dp">
<ImageView
android:id="@+id/ivProfile"
android:layout_width="@dimen/_80dp"
android:background="@drawable/no_image"
android:layout_height="@dimen/_80dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/tv_uName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/titleSize"
android:layout_marginTop="@dimen/_10dp"
android:textColor="@color/colorWhite"
android:text=""
android:gravity="center"
android:layout_gravity="center"
android:textAlignment="center" />
<TextView
android:id="@+id/tv_user_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/textSize"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/colorWhite"
android:layout_marginTop="@dimen/_5dp"
android:text=""
android:textAlignment="center" />
</LinearLayout>
<?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="end">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ll_layout_parent"
android:orientation="vertical">
<include
android:id="@+id/include"
layout="@layout/tool_bar"></include>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ll_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/_55dp"
android:background="@drawable/white_background"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="end">
<LinearLayout
android:layout_width="@dimen/_1dp"
android:layout_height="match_parent"
android:background="@color/colorAccent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="@dimen/_200dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:itemTextColor="@color/colorText">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_navigation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_160dp"
android:listSelector="@color/colorWhite"
android:divider="@null">
</android.support.v7.widget.RecyclerView>
</android.support.design.widget.NavigationView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
public class NavigationDrawerAdapter extends
RecyclerView.Adapter<NavigationDrawerAdapter.MyViewHolder> {
private LayoutInflater inflater;
private List<HashMap<String,String>> 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<HashMap<String,String>>
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);
}
}
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:weightSum="1"
android:layout_margin="@dimen/_15dp">
<ImageView
android:id="@+id/iv_drawerIcon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"/>
<TextView
android:id="@+id/tv_subTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="@dimen/textSize"
android:layout_weight="0.2"
android:textStyle="bold"
android:layout_marginLeft="@dimen/_10dp"
android:textColor="@color/colorWhite" />
</LinearLayout>
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<HashMap<String, String>>(),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();
}
}