Содержимое приложения уходит из нижней части экрана до конца TabWidget? - PullRequest
2 голосов
/ 23 апреля 2011

Я создаю приложение, которое содержит TabWidget вверху.Все выглядит хорошо, за исключением экрана меньшего размера, содержимое с вкладки «исчезает» из нижней части экрана.Я искал решение, использовал только dp / sp, чтобы правильно масштабировать макет ... но ничего не получится.

Я полагаю, что проблема в таб-виджете, так как кажется, что он не масштабируется доновые размеры экрана.Я не знаю, как обеспечить отображение моего таб-контента на всех экранах?Ниже приведен XML-код активности моей вкладки:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:typeface="monospace" 
    android:background="@drawable/target"
    android:paddingRight="25dp"
    android:paddingLeft="25dp"
    android:paddingTop="15dp">

            <TextView
            android:text="Convert from:"
            android:id="@+id/convertFrom"
            android:textColor="#000000"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:typeface="monospace" 
            android:textSize="16dp"/>


           <EditText
               android:inputType="numberDecimal"           
               android:id="@+id/numberInput"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" 
            android:textSize="16dp"
               android:layout_below="@id/convertFrom"/>

            <Spinner 
                android:id="@+id/spinner_one" 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true" 
            android:textSize="16dp"
                android:layout_below="@id/numberInput"></Spinner>

            <TextView
            android:text="Convert to:"
            android:typeface="monospace" 
            android:id="@+id/text_to"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:textSize="16dp"
            android:layout_marginTop="20dp"
            android:layout_below="@id/spinner_one"/>

            <Spinner
            android:id="@+id/spinner_two"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true" 
            android:textSize="16dp"
            android:layout_below="@id/text_to"></Spinner>

            <Button
                android:id="@+id/button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:textSize="16dp"
                android:text="@string/app_name"
                android:layout_below="@id/spinner_two"/>

            <TextView
            android:id="@+id/thisequals"
            android:layout_marginTop="45dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true" 
            android:textSize="20dp"
            android:layout_below="@id/button"
            android:maxLines="1"
            layout_alignParentRight="true"
            layout_alignParentLeft="true"/>

            <TextView
            android:id="@+id/answer"
            android:textColor="#FF4400"
            android:layout_centerHorizontal="true"
            android:textStyle="bold"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:textSize="26dp"
            android:typeface="sans" 
            android:maxLines="1"
            android:layout_below="@id/thisequals"/>

            <TextView
            android:id="@+id/ofthis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:textSize="20dp"
            android:layout_below="@id/answer"/>

</RelativeLayout>

И это main.xml (если необходимо):

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </FrameLayout>
    </LinearLayout>
</TabHost>

Вот изображение проблемы (одно и то же должно отображаться на обоихэкраны .. один HVGA и QVGA)

http://dl.dropbox.com/u/15931335/appproblem.jpg

Спасибо!

Ответы [ 2 ]

0 голосов
/ 25 мая 2011

Не могли бы вы попробовать заменить ваши атрибуты LinearLayout в main.xml на

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp"
    android:orientation="vertical">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weight="1.0">
    </FrameLayout>
</LinearLayout>
0 голосов
/ 23 апреля 2011

Кажется, что для этого макета недостаточно места только из-за небольшого размера экрана. Это нормальная ситуация, когда вы имеете дело с устройствами с маленьким экраном. Вы можете поместить этот макет в представление прокрутки или сделать его меньше, чтобы соответствовать экрану маленьких детей. Я думаю, что вы можете рассматривать экран 320x240 ldpi как самый маленький.

...