【问题标题】:Changing color scheme of Chrisbanes' PullToRefresh Actionbar更改 Chrisbanes 的 PullToRefresh 操作栏的配色方案
【发布时间】:2015-01-22 09:55:44
【问题描述】:

有没有办法改变 Chrisbanes PulToRefresh Actionbar 的配色方案? 我已阅读快速入门 (https://github.com/chrisbanes/ActionBar-PullToRefresh/wiki/QuickStart-Stock) 但未提及。

提前致谢。

【问题讨论】:

  • 你检查自定义here???
  • 是的,我确实注意到有一个 DefaultHeaderTransformer。但是我可以通过任何方式使进度条的颜色从蓝色变为绿色,再从红色变为紫色(例如,每次以 4 种颜色显示进度。)

标签: android android-actionbar pull-to-refresh


【解决方案1】:

如果您查看here,您会发现 actionbar-pull-to-refresh 方法已被弃用,您可以使用以下方法!

1) 检查这个example

2) 编译这个依赖:compile 'com.android.support:support-v4:21.0.+'

3) 修改你的布局文件:

<android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_main_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ListView
            android:id="@+id/activity_main_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
        </ListView>

    </android.support.v4.widget.SwipeRefreshLayout>

4) 在您拥有 ListView 的活动中:

SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
            //refresh your content and after your done call this method to stop refreshing
            mSwipeRefreshLayout.setRefreshing(false);
      });

5) 您还可以自定义 SwipeRefreshLayout 的外观。要定义您自己的自定义配色方案以与 SwipeRefreshLayout 的动画加载图标一起使用,请使用适当命名的 setColorSchemeResources() 方法。

<resources>
    <color name="orange">#FF9900</color>
  <color name="green">#009900</color>
    <color name="blue">#000099</color>
</resources>

希望对你有帮助!!!

【讨论】:

  • 感谢您的帮助。我试过了。它确实有效,但它不是我真正想要的。我的错没有解释得不够透彻,我最想要的是一个带有进度条指示进度的进度条,而不是箭头。就像 Chrisbanes 的 Pull-To-Refresh 操作栏一样,但颜色会不断变化。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-16
  • 1970-01-01
  • 1970-01-01
  • 2017-10-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多