Android box display displayed by fragment

I am adding a box layout to my Actvity, which uses fragments. I implemented this as described here in the Android documentation. And the drawer adapter adapter and “View All” work in that they are displayed, but the drawer expands “under” the contents of the fragment. Here is a picture of what is happening:enter image description here

Does anyone know why this could be? My code for xml activity and actiity add snippet below:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_list); // for drawer navigation
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager
            .beginTransaction();
    fragmentTransaction.replace(android.R.id.content,
            new AlarmListFragment());
    fragmentTransaction.commit();
    setUpDrawer(fragmentManager);
}

    private void setUpDrawer(FragmentManager fm) {
    String[] drawerItems = getResources().getStringArray(
            R.array.drawer_array);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ListView drawerList = (ListView) findViewById(R.id.left_drawer);

    // Set the adapter for the list view
    drawerList.setAdapter(new ArrayAdapter<String>(this,
            R.layout.item_nav_drawer, drawerItems));
    // Set the list click listener
    drawerList.setOnItemClickListener(new
            DrawerItemClickListener(drawer,drawerList,drawerItems,fm));
}

Markup:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
       xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView
        android:id="@+id/alarm_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>
</FrameLayout>

<ListView
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>

Do I need to install z-index? I can provide any additional information that I would really like to know!

+4
source share
2

, FrameLayout, id = content_frame.

,

fragmentTransaction.replace(android.R.id.content,
        new AlarmListFragment());

 fragmentTransaction.replace(R.id.content_frame,
        new AlarmListFragment());
+1

Fragment XML. DrawerLayout . , , .

<RelativeLayout
    android:id="@+id/my_parent_container"
    android:layout_height="match_parent"
    android:layout_width="match_parent" 
    tools:context=".MainActivity"
    xmlns:tools="http://schemas.android.com/tools">
<FrameLayout
    android:id="@+id/fragment_wrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></FrameLayout>

<android.support.v4.widget.DrawerLayout
        android:id="@+id/my_drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns="http://schemas.android.com/apk/res/android">

        <RelativeLayout
             android:id=@+id/drawer_pane"
             android:layout_width="250dp"
             android:layout_height="match_parent"
             android:layout_gravity="end" />
        <ListView xmlns="http://schemas.android.com/apk/res/android"
                android:layout_width="280dp"
                android:layout_height="match_parent"
                android:choiceMode="singleChoice"
                android:id="@+id/menu_list"
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
0

Source: https://habr.com/ru/post/1534052/


All Articles