简体   繁体   English

高宽比的问题

[英]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. 我正在320X480手机上测试我的应用程序,一切看起来都很好,但这是用户的HTC ONE X的屏幕,看起来真的很糟糕。 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 https://www.dropbox.com/s/xc4sjq6e1yo3xkv/Screenshot_2013-05-11-12-11-08.png

Here's my XML: 这是我的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. 我知道这不是最好的方法,但是对于像您这样需要的简单布局,它应该可以完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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