レイアウトをScrollViewに配置することで、レイアウトを垂直にスクロールできるようにする方法を知っています。しかし、どうすればそれをサイドスクロール可能にすることができますか?レイアウトを水平方向と垂直方向にスクロール可能にする方法は?
1
A
答えて
2
ScrollView
およびHorizontalScrollView
は、ユーザが垂直または水平にスクロールして物理ディスプレイよりも大きくできるようにするためのレイアウトコンテナです。 ScrollView/HorizontalScrollView
はFrameLayout
です。つまり、スクロールする内容全体を含む1人の子供をその中に配置する必要があります。この子自体が、オブジェクトの複雑な階層を持つレイアウトマネージャである場合があります。詳細について
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Inside 1st HorizontalScrollView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button A5" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Inside 2nd HorizontalScrollView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B5" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button B6" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Inside ScrollView" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button C" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button D" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button E" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button F" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button G" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button H" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button I" />
</LinearLayout>
</ScrollView>
</LinearLayout>
これを参照してください:http://android-coding.blogspot.in/2011/01/scrollview-and-horizontalscrollview.html
更新:
がvertical
などhorizontal
をスクロールするために、このXMLを使用する。ここ
は、XMLです。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="vertical">
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320px" android:layout_height="fill_parent">
</HorizontalScrollView>
</ScrollView>
関連する問題
- 1. 水平と垂直の両方向にスクロール可能なレイアウト
- 2. 垂直方向と水平方向のスクロール可能なテーブル
- 3. リストを水平方向および垂直方向にスクロール可能にする
- 4. Uiscrollviewは水平方向と垂直方向にスクロールします
- 5. UITableViewを水平方向と垂直方向にスクロール
- 6. ExtJSレイアウト、水平方向に垂直方向に伸びる
- 7. UICollectionViewの垂直スクロール方向と水平スクロール方向
- 8. UItextview水平方向と垂直方向にスクロール
- 9. UIScrollView水平方向と垂直方向をプログラムでスクロール
- 10. 垂直方向にスクロールするときにDIVを水平方向に移動
- 11. フォームを水平方向と垂直方向にセンタリングする
- 12. 可変サイズのdivを垂直方向と水平方向にセンタリングする
- 13. UICollectionViewの項目フロー方向が垂直方向、スクロールが水平方向
- 14. イメージを水平方向と垂直方向に中央に揃える方法
- 15. ViewPagerで垂直方向にスクロールしてページングを水平方向に行う
- 16. 垂直方向と水平方向の両方のデータ
- 17. 水平方向ではなく垂直方向にタブする方法
- 18. イメージを水平方向+垂直方向にフリップ/ミラーで表示
- 19. イオン無限スクロールは水平方向と垂直方向にスクロールしても機能しません
- 20. GridLayoutManagerを水平スクロールで垂直方向にします
- 21. エクシードAvalonDock 2:ドック/アレンジ/水平方向と垂直方向
- 22. 相対テキストセンタリング。垂直方向と水平方向
- 23. フレックスアイテムの垂直方向と水平方向の中心点
- 24. C++ YUYV 422水平方向と垂直方向の反転
- 25. 国境-画像スライススワップ水平方向と垂直方向のparams
- 26. 水平方向と垂直方向の両方に成長するWPFのグリッド
- 27. Qt - スプリッタを水平方向と垂直方向に同時に作成する
- 28. 垂直方向の水平RecyclerView ScrollView
- 29. 水平・垂直両方向スクロールカルーセル効果?
- 30. 連続した線を水平方向と垂直方向にアニメーションする
私が探していたもの、水平スクロールビューが存在するかどうかはわかりませんでした。ただ一つの簡単な質問:レイアウトをスクロール可能にし、同時に水平スクロール可能にする方法? HorizontalScrollViewをScrollViewの子として配置し、元のレイアウトをHorizontalScrollViewの子にするとうまくいくでしょうか? – Leonz
@Leonzは 'HorizontalScrollView'を' ScrollView'の中に入れました。 – Ironman
@Leonz私の更新の回答を見てください。 – Ironman