2014-11-05 57 views
0

我有一個使用horizantalscrollview創建一個滑塊和內部,我添加了一個LinearLayout中添加視圖項曲線背景滑塊在Android的

<HorizontalScrollView> 
      <LinearLayout> 
       view items will be here 
      </LinearLayout> 
</HorizontalScrollView> 

但我根據給定的圖像要曲線邊界在滑塊enter image description here

我怎麼可以曲線backgound只在第一和最後一個,但請注意,此滑塊可以有超過8個元素,所以當它的幻燈片,顯示角的圖像應曲線,C1-C10將圖像

顯示項目

原始圖像

enter image description here

+0

做一個選擇圓角。 – GrIsHu 2014-11-05 06:40:49

回答

0

創建這段代碼自定義繪製,

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

    <gradient 
     android:endColor="@color/black" 
     android:startColor="@color/black" /> 

    <corners android:radius="3dp" /> 

</shape> 

集這個可繪製在Horizo​​ntalScrollView背景

我希望這將幫助你

+0

nope它沒有工作,c1圖像角落應彎曲 – 2014-11-05 06:47:26

+0

@ Mr.G檢查我的答案。 – GrIsHu 2014-11-05 07:11:07

0

試試以下xml文件代碼。名爲rounder_corner_selector.xml創建res/drawable文件夾內的XML文件,並粘貼如下代碼:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:padding="90dp" 
    android:shape="rectangle" > 

    <solid android:color="#000000" /> 

    <corners 
     android:bottomLeftRadius="15dp" 
     android:bottomRightRadius="15dp" 
     android:topLeftRadius="15dp" 
     android:topRightRadius="15dp" /> 

</shape> 

應用上述文件作爲背景,你HorizontalScrollView如下:

<HorizontalScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/round_corner_selector" > 
+0

@GrlsHu,我imeplemted你發送的,它適用於背景,但不適用於拇指,不適合附上原始圖像 – 2014-11-05 07:37:46

+0

@ Mr.G是否要將它應用於您的圖像? – GrIsHu 2014-11-05 08:11:49

+0

是的,但我應該是可見的左側和右側圖像在角落 – 2014-11-05 08:13:06