2014-05-22 143 views
1

好吧,快速背景:我一直在开发简单的音乐播放器应用程序并增强用户体验(特别是在新设备上)我决定使用传说中的SystemBarTint library当使用SystemBarTint时,我的片段被ActionBar选项卡重叠

导入.JAR,按照使用说明,修改了应用程序主题和瞧!我的应用看起来比10年陈旧的自行车更漂亮。 但是等等,还有更多!

enter image description here

正如你所看到的,ListView现在由ActionBar及其选项卡覆盖。我做了功课,发现this解决方法 - 哪些工作,有点。

enter image description here

ListViewActionBar不再包括在内,但它仍然被标签覆盖!

我该如何对此进行排序?

这是我的BaseActivityonCreate方法,其激活SystemBarTint库:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    SystemBarTintManager tintManager = new SystemBarTintManager(this); 

    tintManager.setStatusBarTintEnabled(true); 
    tintManager.setTintColor(getResources().getColor(R.color.wowza_orange)); 
} 

..和这是替代方法,在供给我Fragment(其容纳ListView):

@Override 
public void onViewCreated(View view, Bundle savedInstanceState) { 
    super.onViewCreated(view, savedInstanceState); 

    musicList.setClipToPadding(false); // musicList is my ListView instance. 
    setInsets(getActivity(), (View) musicList); 
} 

public static void setInsets(Activity context, View view) { 

    SystemBarTintManager tintManager = new SystemBarTintManager(context); 
    SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); 

    view.setPadding(0, config.getPixelInsetTop(true), 
      config.getPixelInsetRight(), config.getPixelInsetBottom()); 
} 

由于提前!

回答

1

它有点晚,但我面临同样的问题。我的解决办法是添加这个方法:

private int getActionBarHeight() { 
    int actionBarHeight =0; 
    final TypedValue tv = new TypedValue(); 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 
     if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) 
      actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); 
    } else if (context.getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) 
     actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); 
    return actionBarHeight; 
} 

并替换:

view.setPadding(0, config.getPixelInsetTop(true), 
     config.getPixelInsetRight(), config.getPixelInsetBottom()); 

有:

view.setPadding(0, config.getPixelInsetTop(true) + getActionBarHeight(), 
     config.getPixelInsetRight(), config.getPixelInsetBottom()); 
相关问题