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