2013-11-21 53 views
1

我在我的活動中使用淡入淡出操作欄庫,但我找不到一種方法來設置自定義佈局到操作欄.i只能設置一個可拖動到我的操作欄中圖書館,我試圖尋找內部庫代碼,但它並沒有太大的幫助............有沒有辦法做到這一點。褪色ActionBar Lib的自定義佈局

這裏是如何它通常工作:

  FadingActionBarHelper helper = new FadingActionBarHelper() 
     .actionBarBackground(R.drawable.ab_background) 
     .headerLayout(R.layout.header) 
     .contentLayout(R.layout.activity_profile); 

回答

1

試試這個,它工作在我的身邊

虛增您的自定義操作欄

final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(
      R.layout.actionbar_layout, 
      null); 

配置你的動作條& setCustomView

ActionBar actionBar = getActionBar(); 
    actionBar.setDisplayShowHomeEnabled(false); 
    actionBar.setDisplayShowTitleEnabled(false); 
    actionBar.setDisplayShowCustomEnabled(true); 
    actionBar.setCustomView(actionBarLayout); 

然後使用FadingActionbar代碼

 FadingActionBarHelper helper = new FadingActionBarHelper() 
    .actionBarBackground(R.drawable.ab_background) 
    .headerLayout(R.layout.header) 
    .contentLayout(R.layout.activity_profile); 
+0

是的,它的工作原理! :) –