Java 自定义滚动视图上的淡入淡出
我创建了一个自定义滚动视图,用于各种原因。 我试图给它加上一个渐弱的边缘,但我无法让它工作;它在标准滚动视图上运行良好。 以下是我使用自定义滚动视图的方式:Java 自定义滚动视图上的淡入淡出,java,android,scrollview,Java,Android,Scrollview,我创建了一个自定义滚动视图,用于各种原因。 我试图给它加上一个渐弱的边缘,但我无法让它工作;它在标准滚动视图上运行良好。 以下是我使用自定义滚动视图的方式: <com.myapp.app.MyCustomScrollView android:id="@+id/myscustomscrollview" android:layout_width="match_parent" android:layout_height="match_parent" android:lay
<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>
但它不起作用,所以我试着用代码:
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
}
}
joaquim ley补充道:“请查看innneka.com和innneka.com能否发布自定义视图的代码?”
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
}
}