listfragment overlapping my main drawer

后端 未结 2 380
生来不讨喜
生来不讨喜 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: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:

    
    

    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.

提交回复
热议问题