写一个最原始的Horizontal ProgressBar:
Layout 如下:
<ProgressBar android:id="@+id/progress_bar" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/Widget.AppCompat.ProgressBar.Horizontal" android:max="100"/>
代码:
public class ThirdActivity extends AppCompatActivity { private ImageView try_1; private ProgressBar progressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_third); try_1 = findViewById(R.id.try_1); progressBar = findViewById(R.id.progress_bar); try_1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try_1.setImageResource(R.drawable.try_2); int progress = progressBar.getProgress(); progress = progress+10; progressBar.setProgress(progress); } }); } }