Why the fragment overlaps the Action bar?

故事扮演 提交于 2020-01-23 17:39:11

问题


I tried to use the android support library v7 to add an action bar to my activity my extending tht actionbar activity. A blank fragment has been also built to make a tab. However, the content of the fragment is overlapping the action bar. How can I fix it?


回答1:


I read it here ActionBar with support library and Fragments overlay content I am sure it will help you :

For pre ICS devices you must use:

R.id.action_bar_activity_content

instead of

android.R.id.content

R.id.action_bar_activity_content is a new id used in layout for displaying app content, it would appear that it replace android.R.id.content when you use support v7 appcompat ActionBarActivity.

You can use this code to retrieve the correct id of the activity content :

public static int getContentViewCompat() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH ?
           android.R.id.content : R.id.action_bar_activity_content;
}


来源:https://stackoverflow.com/questions/18043606/why-the-fragment-overlaps-the-action-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!