【MVP】与toolbar相关的实现+progressWheel进度条

自我学习使用,共同进步
之前先要除去系统的状态栏

  <style name="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

再写view_toolbar.xml布局文件,包含toolbar和ProgressWheel

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:wheel="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/blue"
            app:theme="@style/ToolbarStyle" />

        <com.xiaoyuan.hloli.weiget.view.ProgressWheel
            android:id="@+id/progressWheel"
            android:layout_width="25dp"
            android:layout_height="45dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="20dp"
            wheel:matProg_barColor="@color/white"
            wheel:matProg_barWidth="2dp" />
    </RelativeLayout>

</LinearLayout>

在写Java文件

 @Bind(R.id.toolbar)
    @Nullable
    Toolbar toolbar;
    @Bind(R.id.progressWheel)
    @Nullable
    ProgressWheel progressWheel;

    public void initBaseToolbar(int titleResId,Boolean canBack){
        assert toolbar != null;
        toolbar.setTitle(titleResId);
        toolbar.setTitleTextColor(Color.WHITE);
        setSupportActionBar(toolbar);
        if(canBack && getSupportActionBar() != null){
            getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    public void initBaseToolBar(String titleStr, boolean canBack) {
        assert toolbar != null;
        toolbar.setTitle(titleStr);
        toolbar.setTitleTextColor(Color.WHITE);
        setSupportActionBar(toolbar);
        if (canBack && getSupportActionBar() != null) {
            getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    public void showLoading(){
        if (progressWheel != null && !progressWheel.isSpinning()){
            progressWheel.isSpinning();
        }
    }
    public void stopLoading(){
        if (progressWheel !=null&&  progressWheel.isSpinning()){
            progressWheel.stopSpinning();
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值