私は次のレイアウトを持っていますが、コンテンツが表示するには多すぎる場合は縦にスクロールしたいと思います。ImageView の「imagePhoto」は、デバイスのカメラで撮影した画像です。写真がポートレートで撮影された場合、レイアウトはスクロールできる必要があります。次のように、LinearLayout の前に ScrollView を追加してみました。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
しかし、うまくいかなかったようです。
助言がありますか??
レイアウトxmlは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgetUploadPhoto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffff"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/topLevelMenuBackground"
android:orientation="horizontal">
<TextView
android:id="@+id/tvHeaderText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text=""
android:textColor="#ffffffff"
android:textSize="20sp"
android:shadowColor="#7F000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_centerVertical="true" />
</RelativeLayout>
<TextView
android:id="@+id/tvYourCurrentPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Your current photo:"
android:background="#ffffffff"
android:textColor="#ff626262"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingBottom="10dp"
android:textSize="@dimen/text_size_medium"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:visibility="gone" />
<ImageView
android:id="@+id/imagePhoto"
android:src="@drawable/OrangeAccessoryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:background="#ffffffff"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:paddingTop="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:visibility="gone" />
<TextView
android:id="@+id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Select an option below to change your photo."
android:background="#ffffffff"
android:textColor="#ff626262"
android:paddingTop="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:textSize="@dimen/text_size_medium" />
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:focusable="false"
android:layout_weight="1" />
</LinearLayout>
ヘルプ/提案をありがとう。
更新された XML:
注: これは機能しますが、期待される結果ではありません。RelativeView 内のものだけをスクロールしたい。最初の TexView はヘッダーで、固定したままにして、その下のビューをスクロールしたいです。基本的に、すべてスクロールする必要がありますが、関連する vie セクションです。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgetUploadPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/topLevelMenuBackground"
android:orientation="horizontal">
<TextView
android:id="@+id/tvHeaderText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text=""
android:textColor="#ffffffff"
android:textSize="20sp"
android:shadowColor="#7F000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_centerVertical="true" />
</RelativeLayout>
<TextView
android:id="@+id/tvYourCurrentPhoto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Your current photo:"
android:background="#ffffffff"
android:textColor="#ff626262"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingBottom="10dp"
android:textSize="@dimen/text_size_medium"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:visibility="gone" />
<ImageView
android:id="@+id/imagePhoto"
android:src="@drawable/OrangeAccessoryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:background="#ffffffff"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:paddingTop="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:visibility="gone" />
<TextView
android:id="@+id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Select an option below to change your photo."
android:background="#ffffffff"
android:textColor="#ff626262"
android:paddingTop="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:textSize="@dimen/text_size_medium" />
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:focusable="false"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>