Android -ScrollviewのLinearLayout
-
26-10-2019 - |
質問
私のUIは非常にシンプルなので、1つのXMLファイルでランドスケープとポートレートの両方に対応したいと思います。
ポートレートモードでは、すべてが私が望んでいるとおりです。
ランドスケープでは、main_title TextViewがほとんど表示されません。これについては回りますか?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="@color/background"
android:layout_width="fill_parent" android:padding="20dip"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_height="fill_parent"
android:layout_gravity="center" android:orientation="vertical"
android:layout_marginTop="30dip" android:id="@+id/LinearLayout01"
android:layout_width="fill_parent">
<TextView android:layout_marginBottom="15dip"
android:textSize="24.5sp" android:layout_height="wrap_content"
android:id="@+id/TextView01" android:layout_gravity="center"
android:text="@string/main_title" android:layout_width="wrap_content"></TextView>
<Button android:layout_marginBottom="15dip"
android:layout_height="wrap_content" android:id="@+id/start_button"
android:text="@string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:textSize="18sp" android:layout_height="wrap_content"
android:id="@+id/TextView02" android:text="@string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinner"
android:prompt="@string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
<ImageView android:layout_marginTop="60dip" android:id="@+id/info_button"
android:src="@drawable/info" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</LinearLayout>
</ScrollView>
リンク:
解決
問題はあなたにあるようです margin
と padding
値。
最良のオプションは、これに2つの異なるレイアウトを用意することです。1つはポートレートであり、その他の景観です。名前の別のフォルダーを作成します layout-land
と layout-port
あなたの中で res
フォルダ。次に、これらのフォルダーの両方にレイアウトファイルをコピーし、方向に適切な変更を加えます。
さまざまなオリエンテーションなどのさまざまなリソースを提供することについての詳細については、Androidドキュメントを参照してください。 http://developer.android.com/guide/topics/resources/providing-resources.html#alternativeresources
他のヒント
ファイルの上部に空白のテキストビューを追加します。つまり、表示されていないTextViewの上にあります。たぶん、あなたのコンテンツ領域は非常に大きく、画面はそれをサポートできません。あなたが直面している問題は、そもそも起こってはいけません....しかし、これは回避策です。また、エミュレーターを切り替えてみてください...
所属していません StackOverflow