0

私の 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>

リンク:

http://www.doc.ic.ac.uk/~am907/landscape.png

http://www.doc.ic.ac.uk/~am907/portrait.png

4

2 に答える 2

1

問題はあなたmarginpadding価値観にあるようです。

最適なオプションは、このために 2 つの異なるレイアウトを用意することです。1 つは縦向きで、もう 1 つは横向きです。layout-landフォルダー内にandという名前の別のフォルダーを作成layout-portresます。次に、レイアウト ファイルをこれらの両方のフォルダーにコピーし、向きを適切に変更します。

さまざまな向きなどにさまざまなリソースを提供する方法の詳細については、Android ドキュメントを参照してください: http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

于 2011-03-16T18:08:35.487 に答える
0

ファイルの上部、つまり表示されていないテキストビューの上に空白のテキストビューを追加します。コンテンツ領域が非常に大きく、画面がそれをサポートできない可能性があります。あなたが直面している問題は、そもそも発生していないはずです....しかし、これは回避策です。また、エミュレータを切り替えてみてください...

于 2011-03-16T17:22:07.303 に答える