簡體   English   中英

自定義滾動視圖淡入淡出

[英]Fading on custom scrollview

我創建了一個自定義滾動視圖,出於各種原因使用。 我正在嘗試對其應用漸隱邊緣,但無法使其正常工作; 它在標准滾動視圖上運行良好。 這是我使用自定義滾動視圖的方式:

<com.myapp.app.MyCustomScrollView
   android:id="@+id/myscustomscrollview"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:layout_margin="10dp">
   <LinearLayout...

   </LinearLayout>
</com.myapp.app.MyCustomScrollView>

我試圖通過這樣的 XML 添加淡入淡出:

android:requiresFadingEdge="vertical"
android:fadingEdgeLength="5dp"

它沒有用,所以我通過代碼嘗試:

myscustomscrollview.setHorizontalFadingEdgeEnabled(true);
myscustomscrollview.setFadingEdgeLength(FADING_SIZE);

它也不起作用。

這是我的自定義視圖,我只是擴展了 Scrollview 並覆蓋了一個方法

public class MyCustomScrollView extends ScrollView {
    public MyCustomScrollView(Context context) {
        super(context);
    }

    public MyCustomScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyCustomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        //Custom logic
    }
}

innneka.com 中查看此答案此答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM