我在我的一个小部件中使用Android进度条:
<ProgressBar
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
机器人:targetSdkVersion
到“15”进度条看起来完全不同。它现在是一条细蓝线而不是条形。问题是我在进度条上面写了一些文字,特别是进度的百分比。 因此,当酒吧很薄,这看起来很奇怪。
我无法弄清楚如何再次将条的高度增加到例如50dp。如果我尝试android:layout_height =“50dp”它仍然保持相同的状态。
答案 0 :(得分:9)
首先,您需要在项目的values-&gt; 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中添加:
风格=&#34; @风格/ tallerBarStyle&#34;
希望有所帮助。 :)
答案 1 :(得分:1)
您需要替换
style=”?android:attr/progressBarStyleHorizontal”
到
style="@android:style/Widget.ProgressBar.Horizontal"
和layout_height将起作用
android:layout_height="50dp"