Android 進度條可以通過以下步驟實現無障礙訪問:
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"/>
ProgressBar progressBar = findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(50);
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:contentDescription="@string/progress_bar_description"/>
在strings.xml文件中添加無障礙描述:
<string name="progress_bar_description">正在加載,請稍候</string>
if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE);
}
if (progressBar.getProgress() == 0) {
progressBar.setProgress(50);
}
以上步驟可以實現Android進度條的無障礙訪問。