3

是否可以在调整大小以适应所有屏幕尺寸的情况下创建liquid/elastic屏幕布局?Android

目前,我正在为小型、中型、大型、xlarge 等使用不同的布局,但我真正需要的是一个可以缩放以适应的单一布局。

例如。基于百分比的布局。

我正在创建的应用程序并不特别需要利用更大的屏幕来更多地利用空间。

主屏幕只有 2 张图片、一堆按钮和底部的广告,我只是希望广告保持在底部,而其他所有内容都会根据屏幕尺寸相应放大。

为一个非常简单的界面设计 4 种不同的布局似乎过于复杂。

建议非常感谢!

4

1 回答 1

2

您可以使用 相对布局

或者

具有权重的布局,例如

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:scaleType="fitXY"
            android:src="@drawable/ic_launcher" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:scaleType="fitXY"
            android:src="@drawable/ic_launcher" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />

            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>
    </LinearLayout>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:gravity="center"
        android:text="ADV" />

</LinearLayout>
于 2013-05-02T06:50:28.413 回答