2013-05-22 99 views
2

我需要編輯seekbar的佈局。搜索欄佈局文件,我有:編輯seekbar的佈局不起作用

<SeekBar 
      android:id="@+id/seekBar1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:progress="0" 
      android:progressDrawable="@drawable/seek" 
      android:thumb="@drawable/thumb" /> 

而繪製/追求的是:

<?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item android:id="@android:id/background" android:drawable="@drawable/time_passivo"/> 
    <item android:id="@android:id/progress" android:drawable="@drawable/time_attivo" /> 

    </layer-list> 

我想是這樣的形象:

wrong seek

而是我得到這個:

correct seek

只要我用2個圖像爲尋求信息...(PNG) time_attivo http://i44.tinypic.com/e5qps9.png time_passivo http://i40.tinypic.com/2vngv9j.png

和拇指是另一個PNG

編輯

我試圖做它用9路,但它並沒有解決我的問題。

的9path是: time_attivo_9patch http://i41.tinypic.com/ht9um1.png time_passivo_9patch http://i42.tinypic.com/2v0ml28.png

但求沒有工作seek http://i43.tinypic.com/16qxe1.png

+0

post'@ drawable/time_passivo'和'@ drawable/time_attivo'對我來說就像你試圖製作9patch圖像一樣,並且沒有將它們設置爲完全正確。但是,如果看不到您的繪圖,我們無法分辨。 – FoamyGuy

+0

你說的是seekbar的大小?爲了給你一些幫助,我們需要知道包裝佈局視圖。所以請添加完整(或至少更多)的佈局xml。 – hcpl

+0

我已經插入了2張圖片time_attivo和time_passivo – Lele

回答

2

我解決了這個問題。 我沒有使用的靜態圖片,但用代碼畫了這一切

酒吧:

<SeekBar android:id="@+id/seekBar1" style="@style/PowerSeekBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/TextViewStop" android:layout_toRightOf="@+id/textViewStart" android:minHeight="6dp" android:maxHeight="6dp" android:paddingLeft="5dip" android:paddingRight="5dip" android:progress="2"
android:thumb="@drawable/thumb" />

和風格:

<!-- Seekbar player --> <style name="PowerSeekBar" parent="android:Widget.SeekBar"> <item name="android:progressDrawable">@drawable/seek</item> <item name="android:thumbOffset">0dip</item> </style>

<?xml version="1.0" encoding="UTF-8"?> 
<layer-list 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
    android:id="@android:id/background"> 
     <shape> 
     <corners 
      android:radius="3dip" /> 
     <gradient 
      android:startColor="#ffcccccc" 
      android:endColor="#9d9d9d" 
      android:centerY="0.50" 
      android:angle="270" /> 
     </shape> 
    </item> 

    <item 
    android:id="@android:id/progress"> 
     <clip> 
     <shape> 
      <corners 
       android:radius="3dip" /> 
      <gradient 
       android:startColor="#ffd92034" 
       android:endColor="#ffad192a" 
       android:angle="270" /> 
     </shape> 
     </clip> 
    </item> 
</layer-list> 

感謝所有。