在低版本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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。