Giải pháp hoàn chỉnh cho vấn đề này sẽ như sau. Chỉ trong trường hợp nếu ai đó cần mảnh mã, đây là những gì tôi đã làm.
- sao chép tất cả các 8 không xác định drawables progressbar ngang
- Edited các drawables sử dụng một số hình ảnh thao túng và loại bỏ miếng đệm không cần thiết
- sao chép XML drawable tên progress_indeterminate_horizontal_holo.xml từ android nền tảng
- sao chép phong cách Widget. ProgressBar.Horizontal và cha mẹ của nó
- Đặt kiểu và chỉnh sửa theo cách thủ công trong bố cục
Đây là progress_indeterminate_horizontal_holo.xml
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/progressbar_indeterminate_holo1" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo2" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo3" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo4" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo5" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo6" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo7" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo8" android:duration="50" />
nguồn Phong cách sao chép vào tập tin phong cách địa phương của tôi.
<style name="Widget">
<item name="android:textAppearance">@android:attr/textAppearance</item>
</style>
<style name="Widget.ProgressBar">
<item name="android:indeterminateOnly">true</item>
<item name="android:indeterminateBehavior">repeat</item>
<item name="android:indeterminateDuration">3500</item>
</style>
<style name="Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_holo</item>
</style>
Và cuối cùng, đặt chiều cao tối thiểu thành 4dp trong tệp bố cục cục bộ của tôi.
<ProgressBar
android:id="@+id/pb_loading"
style="@style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:minHeight="4dp"
android:minWidth="48dp"
android:progressDrawable="@drawable/progress_indeterminate_horizontal_holo" />
Nguồn
2013-09-16 04:37:21
Mức độ mạnh mẽ này sẽ chống lại những thay đổi trong các kiểu mặc định như thế nào? Họ có được bảo đảm tìm kiếm và làm việc tương tự cho tất cả vĩnh cửu hay họ có thể thay thế chúng một cách lý thuyết bất cứ lúc nào bằng cách đẩy nó lên 6 pixel sẽ tạo ra vấn đề (ví dụ: thanh tiến trình vô hình)? – Joey
Tính năng này không hoạt động trên mọi thiết bị. Trên Galaxy S6, ngay cả với lề trên '-6dp', khoảng trắng phía trên thanh tiến trình vẫn hiển thị. –