在低版本Android中fragment会overlay ActionBar区域

1 问题

It works like a charm on android 4.0+ and also on android 2.3 with a normal Activity that has setContentView in onCreate, but when the activity is loading an Fragment in onCreate the ActionBar gets overlapped with the content of my layout. At all other scenarios the ActionBar works well.
2 解释

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.
3 解决方案

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

感谢大神:

https://code.google.com/p/android/issues/detail?id=58108

在低版本Android中fragment会overlay ActionBar区域

上一篇:Dowhile循环


下一篇:while循环与dowhile循环