【问题标题】:Custom layout for Fading ActionBar LibFading ActionBar Lib 的自定义布局
【发布时间】:2013-11-21 12:15:11
【问题描述】:

我在我的活动中使用 Fading 操作栏库,但我找不到为操作栏设置自定义布局的方法。我只能在这个库中为我的操作栏设置一个可绘制对象,我试着往里面看库代码,但它并没有太大帮助............无论如何都可以这样做。

这是它通常的工作方式:

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

【问题讨论】:

    标签: java android eclipse android-library


    【解决方案1】:

    试试这个,对我有用

    为您的自定义操作栏充气

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

    配置您的操作栏和设置自定义视图

        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);
    

    【讨论】:

      【解决方案2】:

      我将 FadingActionBar 的兼容版本与 ActionBar Compat 库一起使用。你可以在https://github.com/felixWackernagel/FadingActionBar-Compat找到它。

      【讨论】:

        【解决方案3】:

        看看this 提到的FadingActionBar。这很简单,您将了解该库的工作原理。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-01-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多