Android 简单实现 进度条 直线 ,圆圈简单实现

首先是对应的布局

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

    <ProgressBar
        android:id="@+id/pb_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <ProgressBar
        android:id="@+id/pb_botton"
        android:layout_below="@id/pb_top"
        android:layout_marginTop="20dp"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:max="100"/>
    <Button
        android:id="@+id/btn_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/pb_botton"
        android:text="add"
        android:textSize="30dp"
        android:layout_marginTop="30dp"/>


</LinearLayout>

下面是对应的代码

public class JdtActivity extends AppCompatActivity {
    private Button btn_add;
    private ProgressBar pb_bottom;
    private int progress=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jdt);
        btn_add= (Button) findViewById(R.id.btn_add);
        pb_bottom= (ProgressBar) findViewById(R.id.pb_botton);
        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(progress<100){
                    progress+=10;
                    pb_bottom.setProgress(progress);
                }else {//进度条循环显示
                    progress=0;
                    pb_bottom.setProgress(progress);
                }
            }
        });



    }

}

就是一个简单实现 ,大神勿喷

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值