2014-05-22 76 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()); 
相關問題