android - 为 Android 创建单个弹性/液体布局屏幕

标签 android resize liquid-layout elasticlayout

是否可以在 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>

关于android - 为 Android 创建单个弹性/液体布局屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16331501/

相关文章:

android - 在工具栏中添加 searchView 时出现布局问题( fragment )

android:windowSoftInputMode ="stateAlwaysHidden|adjustPan"不适用于所有设备

wpf - 如何在WPF中设置可调整字体大小的文本 block 或标签?

Java 使用 slider 调整形状大小

html - 使用 CSS 制作带有边距的均匀大小的 div 的液体网格

android - 如果该号码已占用,请重拨或重新加载 href 电话

android - MissingPluginException(在 channel plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的实现) Release模式

带有 Volley 的 Android 离线请求

css - 流式布局中的最小边距

css - 液体固定液体设计的布局......似乎无法正确处理