2013-05-13 97 views
7

我正在尋找一個工作得很好的酒吧。但是我想增加進度條的高度,因爲原生高度不是很高。尋求酒吧增加高度

因此,我可以動態地或通過XML更改進度條的高度?

+0

- 您是否修復了XML中seekbar的高度? – TheFlash 2013-05-13 07:12:03

回答

18

你可以通過XML來做到這一點。

它可以在您的應用程序中正常工作。您可以在您提到的進度條標籤的XML中進行這種簡單集成。

首先,您需要在項目的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編輯到您想要達到的高度。

然後在你的進度補充:

android:style="@style/tallerBarStyle" 

這將很好地工作。

9

您必須爲所有方向添加一些填充還設置seekbar的最小和最大高度。 這裏是我使用的一個例子。

<?xml version="1.0" encoding="utf-8"?> 
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:progressDrawable="@drawable/custom_player_seekbar_background" 
     android:paddingTop="10px" 
     android:paddingBottom="10px" 
     android:thumb="@drawable/bt_do_player" 
     android:paddingLeft="30px" 
     android:paddingRight="30px" 
     android:minHeight="6dip" 
     android:maxHeight="6dip" 
     android:layout_centerVertical="true"/>