listfragment overlapping my main drawer

后端 未结 2 379
生来不讨喜
生来不讨喜 2021-01-27 22:32

im new in android im creating an app and i have a problem with a listfragment, because the list its showing but its overlapping the title bar(i had to add margin top to change t

相关标签:
2条回答
  • 2021-01-27 23:21

    Revers the order of your activity layout, put list view brfore any other main content

    0 讨论(0)
  • 2021-01-27 23:22

    your problem is your setting your list fragment to the whole view Id with this line

    // android.R.id.content is the WHOLE screen of your Activity
    transaction.add(android.R.id.content,fragmento,"fragmento");
    transaction.commit();
    

    Create a FrameLayout in your content_drawer_principal.xml:

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

    then do:

    transaction.add(R.id.list_content,fragmento,"fragmento");
    transaction.commit();
    

    UPDATE

    The real problem here is that your telling your FragmentTransaction to load your FragmentoPrincipalChofer into android.R.id.content which is a reserved id

    android.R.id.content gives you the root element of a view, without having to know its actual name/type/ID.

    0 讨论(0)
提交回复
热议问题