自定義內部環進度條

在這裏插入圖片描述

public class TableDetalPager extends MenuDetalBassPager {

    /*初始化佈局*/
    private RefreshListview listview;
  public View initView() {
        View view=View.inflate(context, R.layout.tabletail_pager,null);
        /*實例化tabletail_pager.xml
        * */
        listview=(RefreshListview)view.findViewById(R.id.listview);
}
}
package android.pims.com.beijingnews.view;

import android.content.Context;
import android.pims.com.beijingnews.R;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class RefreshListview extends ListView {
    /*
    * 下拉刷新和頂部輪播圖
    * */
    private LinearLayout headerView;
    /*
    * 實例化下拉刷新控件
    * */
    private View ll_pull_drown_refresh;
    private ImageView iv_arrow;
    private ProgressBar pb_status;
    private TextView tv_status;
    private TextView tv_time;
    
    
    


    public RefreshListview(Context context) {
        this(context,null);
    }

    public RefreshListview(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public RefreshListview(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    
        initHeaderView(context);
    
    }

    private void initHeaderView(Context context) {
       headerView= (LinearLayout) View.inflate(context,R.layout.refresh_header,null);

       /*
       *  實例化下拉刷新控件
       * */
      ll_pull_drown_refresh= headerView.findViewById(R.id.ll_pull_drown_refresh);
      iv_arrow=(ImageView) headerView.findViewById(R.id.iv_arrow);
      pb_status=(ProgressBar)headerView.findViewById(R.id.pb_status);
      tv_status=(TextView) headerView.findViewById(R.id.tv_status);
      tv_time=(TextView) headerView.findViewById(R.id.tv_time);

      //添加ListView的頭
        addHeaderView(headerView);

    }
}

佈局文件定義

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

  <ProgressBar
                android:indeterminateDrawable="@drawable/custom_progressbar"
                android:layout_width="80dp"
                android:layout_height="80dp" />

</LinearLayout>

@drawable/custom_progressbar"

<?xml version="1.0" encoding="utf-8"?>
<!--旋轉0-360度-->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegress="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    >

<!--android:useLevel="false" 持續顯現
android:innerRadiusRatio="2.5" 內部環比例
android:thicknessRatio="15"  內部環厚度
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="2.5"
    android:thicknessRatio="15"
    android:useLevel="false"
    >
    <!--漸變-->
    <gradient android:startColor="#ff0000"
        android:centerColor="#88ff0000"
        android:endColor="#ffffff"
        android:type="sweep"></gradient>

</shape>

</rotate>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章