为Android创建一个单一的弹性/液体布局屏幕



是否有可能在Android上创建一个liquid/elastic屏幕布局,调整大小以适应所有屏幕尺寸?

目前我正在玩不同的布局小,中,大,超大等,但所有我真正需要的是一个单一的布局,只是缩放到适合。

。基于百分比的布局。

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

主屏幕只有2张图片,一堆按钮和底部的广告,我只是希望广告保持在底部,而其他一切都根据屏幕大小相应地缩放。

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

建议非常感谢!

你可以使用RelativeLayout

设置权重为

的布局
<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>

最新更新