简体   繁体   中英

Android stretch screen to fit bigger screen size

How can I enlarge my activity when it is running on bigger screen? I have tried android:scaleType="fitXY" for my imageview but it doesn't work. I have tried plenty of code i researched but none of them work. When I run it on Samsung galaxy S2, it work perfectly. But when I tried it on galaxy note or galaxy S2, the UI is totally different. All imageview are small.

Here's the UI for S2:

S2

Here's the UI for note and S3:

S3 /笔记

Here's the xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:contentDescription="@string/imageDesc"
        android:src="@drawable/welcome" />

    <Button
        android:id="@+id/btnFinance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="240dp"
        android:background="@drawable/btn_finance" />

    <Button
        android:id="@+id/btnHowtouse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="305dp"
        android:background="@drawable/btn_howto" />

    <Button
        android:id="@+id/btnSettings"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="370dp"
        android:background="@drawable/btn_settings" />

    <Button
        android:id="@+id/btnAbout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="435dp"
        android:background="@drawable/btn_about" />

</RelativeLayout>

You can make different images and layouts for each resolution.

Use folders for the different image resolution like drawable-hdpi and drawable-xhdpi

I suggest to read here for more details: Supporting Multiple Screens

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM