Is it possible create a liquid/elastic
screen layout on Android
that resizes to fit all screen sizes?
Currently I'm playing around with different layouts for small, medium, large, xlarge etc, but all I really need is a single layout that just scales to fit.
Eg. a percentage based layout.
The app I'm creating doesn't specifically need to take advantage of larger screens in terms of making more use of the space.
The home screen is just 2 images, a bunch of buttons, and an advert at the bottom, and I simply wish for the advert to remain at the bottom, whilst everything else scales up accordingly depending on screen size.
It seems very over-complicated to have to product 4 different layouts for a very simplistic interface.
Advice much appreciated!
You can use RelativeLayout
or
Layout with Weights like
<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>