レイアウトを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. UITableViewを水平方向と垂直方向にスクロール
- 4. ExtJSレイアウト、水平方向に垂直方向に伸びる
- 5. UICollectionViewの垂直スクロール方向と水平スクロール方向
- 6. UIScrollView水平方向と垂直方向をプログラムでスクロール
- 7. フォームを水平方向と垂直方向にセンタリングする
- 8. UICollectionViewの項目フロー方向が垂直方向、スクロールが水平方向
- 9. 可変サイズのdivを垂直方向と水平方向にセンタリングする
- 10. イメージを水平方向と垂直方向に中央に揃える方法
- 11. 水平方向ではなく垂直方向にタブする方法
- 12. イメージを水平方向+垂直方向にフリップ/ミラーで表示
- 13. 相対テキストセンタリング。垂直方向と水平方向
- 14. フレックスアイテムの垂直方向と水平方向の中心点
- 15. C++ YUYV 422水平方向と垂直方向の反転
- 16. 国境-画像スライススワップ水平方向と垂直方向のparams
- 17. 水平方向と垂直方向の両方に成長するWPFのグリッド
- 18. Qt - スプリッタを水平方向と垂直方向に同時に作成する
- 19. 垂直方向の水平RecyclerView ScrollView
- 20. 連続した線を水平方向と垂直方向にアニメーションする
- 21. CSSの垂直方向と水平方向の両方の揃え方は?
- 22. 使用可能なスペースに応じて水平方向または垂直方向にリストを整形する
- 23. WPFでの水平方向から垂直方向のWrapPanel
- 24. スタックバーチャートの向きをD3で垂直方向から水平方向に変更
- 25. ボタンを垂直方向と水平方向の中心に合わせる
- 26. ブートストラップのNavbarを水平方向と垂直方向に合わせる
- 27. div内のテキストを水平方向と垂直方向に合わせる
- 28. Android:TextView水平方向にスクロール
- 29. divsは水平方向と垂直方向に重ならない
- 30. クリック可能div画像を垂直方向と水平方向の中心に合わせる
私が探していたもの、水平スクロールビューが存在するかどうかはわかりませんでした。ただ一つの簡単な質問:レイアウトをスクロール可能にし、同時に水平スクロール可能にする方法? HorizontalScrollViewをScrollViewの子として配置し、元のレイアウトをHorizontalScrollViewの子にするとうまくいくでしょうか? – Leonz
@Leonzは 'HorizontalScrollView'を' ScrollView'の中に入れました。 – Ironman
@Leonz私の更新の回答を見てください。 – Ironman