2012-09-20 69 views
2

我必須爲Android創建SeekBar樣式,並且無法弄清楚如何執行此操作。這是最終結果的圖片(我希望達到)。Android SeekBar定製

enter image description here

讓我們開始與搜索欄的背景。我試圖將它分成三部分:左側圓形結束,中間部分的可重複部分和右側圓形結束。並且它們應該與下一個代碼(foo_background.xml)結合。

<?xml version="1.0" encoding="utf-8"?> 
<clip xmlns:android="http://schemas.android.com/apk/res/android" 
    android:clipOrientation="horizontal" > 

    <bitmap 
     android:antialias="true" 
     android:dither="false" 
     android:filter="false" 
     android:gravity="left|center_vertical" 
     android:src="@drawable/foo_left" 
     android:tileMode="disabled" /> 
    <bitmap 
     android:antialias="true" 
     android:dither="false" 
     android:filter="false" 
     android:gravity="center_vertical" 
     android:src="@drawable/foo_middle" 
     android:tileMode="repeat" /> 
    <bitmap 
     android:antialias="true" 
     android:dither="false" 
     android:filter="false" 
     android:gravity="right|center_vertical" 
     android:src="@drawable/foo_right" 
     android:tileMode="disabled" /> 

</clip> 

這是SeekBar的背景可繪製文件中使用。

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item android:id="@android:id/background"> 
     <clip android:drawable="@drawable/foo_background" /> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip android:drawable="@drawable/seek_bar_progress" /> 
    </item> 

</layer-list> 

但由於所有這些東西的結果我看到一個空的(或更好的說,我沒有看到它)搜索欄進度線。

有沒有人知道如何以正確的方式做到這一點? 非常感謝您的幫助。

+0

您可以觀看鏈接教程http://webtutsdepot.com/2011/12/03/ android-sdk-tutorial-seekbar-example/ –

回答