如何创建水平进度指示器(显示在图像中)

时间:2016-12-19 08:06:29

标签: android android-layout progress-bar

如何创建一个水平进度指示器(在图像中显示),使其处于xml中,我们可以设置一个百分比值,例如,如果我们将值设置为50,那么它是半填充enter image description here

1 个答案:

答案 0 :(得分:1)

您可以在XML中设置进度

 <ProgressBar
  android:id="@+id/progressBar"
  style="?android:attr/progressBarStyleHorizontal"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:progress="20"/>

并通过JAVA

 ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
 progressBar.setProgress(50);