简体   繁体   中英

Troubles with aspect ratio

I'm testing my app on 320X480 phone and everything looks fine, but here's a screen from user's HTC ONE X, and it looks really bad. It should look just like that but over the entire screen.

https://www.dropbox.com/s/xc4sjq6e1yo3xkv/Screenshot_2013-05-11-12-11-08.png

Here's my XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/background" >

    <TextView
        android:id="@+id/tvKviz"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="5dp"
        android:text="Kviz opšte kulture!"
        android:textSize="35sp" />

    <Button
        android:id="@+id/bStart"
        android:layout_width="170dp"
        android:layout_height="48dp"
        android:padding="0dp"
        android:layout_gravity="center"
        android:layout_marginTop="15dp"
        android:background="@drawable/buttons"
        android:text="Start"
        android:textSize="26sp" />

    <Button
        android:id="@+id/bTopScores"
        android:layout_width="170dp"
        android:layout_height="48dp"
        android:padding="0dp"
        android:layout_gravity="center"
        android:layout_marginTop="10dp"
        android:background="@drawable/buttons"
        android:text="Tabela"
        android:textSize="26sp" />

        <Button
            android:id="@+id/bPodesavanja"
            android:layout_width="170dp"
            android:layout_height="48dp"
            android:padding="0dp"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:background="@drawable/buttons"
            android:text="Podešavanja"
            android:textSize="26sp" />

                <Button
                    android:id="@+id/bPravila"
                    android:layout_width="170dp"
                    android:layout_height="48dp"
                    android:padding="0dp"
                    android:layout_gravity="center"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/buttons"
                    android:text="Pravila"
                    android:textSize="26sp" />

                <Button
                    android:id="@+id/bKontakt"
                    android:layout_width="170dp"
                    android:layout_height="48dp"
                    android:padding="0dp"
                    android:layout_gravity="center"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/buttons"
                    android:text="Kontakt"
                    android:textSize="26sp" />

                 <Button
                     android:id="@+id/bIzlaz"
                     android:layout_width="170dp"
                     android:layout_height="48dp"
                     android:padding="0dp"
                     android:layout_gravity="center"
                     android:layout_marginTop="10dp"
                     android:background="@drawable/buttons"
                     android:text="Izlaz"
                     android:textSize="26sp" />

                 <com.google.ads.AdView
                     android:id="@+id/adViewMenu"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="20dp"
                     ads:adSize="BANNER"
                     ads:adUnitId="a1518a6ce0420ab"
                     ads:loadAdOnCreate="true" />

</LinearLayout>

Here is the sample of layout. Using weights to determine sizes should help you achieve what you want. If you don't have different images for different screen sizes using weighs may help.

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"></LinearLayout>
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="10"
        android:orientation="horizontal">
        <LinearLayout 
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>
        <LinearLayout 
            android:id="@+id/btn_container"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <!-- put you buttons in here, and use weights for balancing the menu -->
        </LinearLayout>
        <LinearLayout 
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"></LinearLayout>
    </LinearLayout>
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"></LinearLayout>
</LinearLayout> 

I hope this helps. I know this is not the best way, but for a simple layout like the one you need it should do the job.

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