縦スクロールと横スクロールを入れ子にして、斜めのスクロールを実現するためのクラス。
【MyScrollView.java】
public class MyScrollView extends NestedScrollView {
public MyScrollView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
}
public MyScrollView(Context context, AttributeSet attrs){
super(context, attrs);
}
public MyScrollView(Context context){
super(context);
}
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept){
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event){
onTouchEvent(event);
return false;
}
}
【xml】
<?xml version="1.0" encoding="utf-8"?>
<com.packagename.testviewer3.MyScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:ignore="ObsoleteLayoutParam">
<ImageView
android:id="@+id/image_view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription" />
</LinearLayout>
</HorizontalScrollView>
</com.packagename.testviewer3.MyScrollView>
フルスクロール参考
Android: 画面サイズよりも大きいViewを縦/横/斜めでスクロールする
装飾を省いた画像表示の基礎部分を記録。