2013-10-30 88 views
1

我試圖爲簡單的Horizo​​ntalScrollView添加淡化邊緣。有關fadingEdge屬性的文檔:Horizo​​ntalScrollView fadingEdge

此屬性已被棄用,並將在API級別14(ICE_CREAM_SANDWICH)時被忽略。使用漸變邊緣可能會引入明顯的性能下降,並且只能在應用程序的視覺設計需要時使用。要請求API等級14及以上的衰落邊緣,請改用android:requiresFadingEdge屬性。

好的,但這種佈局不顯示任何衰落的邊緣,太:

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:requiresFadingEdge="horizontal" 
    android:fadingEdgeLength="50dp" 
    tools:context=".MainActivity" > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 

     ... 

    </LinearLayout> 

</HorizontalScrollView> 

我缺少什麼?

回答

0

嘗試使用android:overScrollMode屬性。

只需添加

android:overScrollMode="always" 

HorizontalScrollView

android:overScrollMode可以有三個值:「always」,「never」,「ifContentScrolls」。

+3

overScroll和fadingEdges是不同的東西 – Ekz

+0

你說得對,我的壞。我在這裏測試了你的佈局,它正在工作。也許還有別的東西會導致你的衰落邊緣不能顯示。 – caioyassoyama

+1

其實這是一個老問題。我還沒有找到答案,並解決了我加入到'Horizo​​ntalScrollView'的onDraw()方法的問題,我自己實現了衰落邊緣。像魅力一樣工作。 – Ekz