Android 進(jìn)度條可以通過(guò)以下步驟實(shí)現(xiàn)無(wú)障礙訪問(wèn):
<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文件中添加無(wú)障礙描述:
<string name="progress_bar_description">正在加載,請(qǐng)稍候</string>
if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE);
}
if (progressBar.getProgress() == 0) {
progressBar.setProgress(50);
}
以上步驟可以實(shí)現(xiàn)Android進(jìn)度條的無(wú)障礙訪問(wèn)。