goo blog サービス終了のお知らせ 

タブレット用プログラムの書き止め

android OS & iPadOS の記録。

記録5:NestedScrollView デベロッパーで推奨

2021-07-11 02:12:48 | Android studio 日記

 縦スクロールと横スクロールを入れ子にして、斜めのスクロールを実現するためのクラス。

 

【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を縦/横/斜めでスクロールする

 

 装飾を省いた画像表示の基礎部分を記録。

 

この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« 記録4:ViewSwitcher で画像... | トップ | fragment は部品 »

Android studio 日記」カテゴリの最新記事