我在其中一个小部件中使用 Android 进度条:
<rogressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressbar_Horizontal"
android:max="100"/>
在 Android 2.x 中看起来不错,如下图所示。我已经在栏本身的顶部写了 %。
但如果我在 Android Manifest 中更改
android:targetSdkVersion
到“15”时,进度条看起来完全不同。它现在是一条细蓝线,而不是一条条。问题是我在进度条上方写了一些文字,特别是进度的百分比。
因此,由于酒吧很薄,这看起来很奇怪。
我无法弄清楚如何再次将条形高度增加到例如50dp。如果我尝试 android:layout_height="50dp"它仍然保持同样的薄。
Best Answer-推荐答案 strong>
首先,您需要在项目的 values->styles.xml 中定义进度条的样式。类似:
<style name="tallerBarStyle" parent="@android:style/Widget.SeekBar">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
<item name="android:minHeight">8dip</item>
<item name="android:maxHeight">20dip</item>
</style>
将 maxHeight 编辑为您想要的高度。
然后在你的 ProgressBar 添加:
style="@style/tallerBarStyle"
希望对您有所帮助。
关于android - 如何在 ICS/JB 中增加 ProgressBar 的高度,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/12607327/
|