Вопрос

Поскольку мой пользовательский интерфейс довольно прост, я хотел бы обслуживать как ландшафт, так и портрет в одном 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

Это было полезно?

Решение

Похоже, проблема заключается в margin а также padding ценности.

Лучший вариант может состоять в том, чтобы иметь 2 разных макета для этого, 1 - портрет, а другие - ландшафт. Создайте еще одну папку с именем layout-land а также layout-port в твоей res папка. Затем скопируйте файл макета в обе эти папки и внесите соответствующие изменения для ориентации.

Смотрите Android Docs для получения дополнительной информации о предоставлении различных ресурсов для различных ориентаций и так далее: http://developer.android.com/guide/topics/resources/providing-resources.html#alternativeresources

Другие советы

Добавьте пустой TextView в верхней части файла, то есть над TextView, который не виден. Может быть, ваша область контента очень большая, и экран не может его поддержать. Проблема, с которой вы столкнетесь, не должна происходить в первую очередь ... но это обойтись. Также попробуйте переключить эмуляторы ...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top