[英]Troubles with aspect ratio
我正在320X480手機上測試我的應用程序,一切看起來都很好,但這是用戶的HTC ONE X的屏幕,看起來真的很糟糕。 它看起來應該像這樣,但要覆蓋整個屏幕。
https://www.dropbox.com/s/xc4sjq6e1yo3xkv/Screenshot_2013-05-11-12-11-08.png
這是我的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>
這是布局示例。 使用權重確定大小應該可以幫助您實現所需的目標。 如果對於不同的屏幕尺寸沒有不同的圖像,則可以使用稱重功能。
<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>
我希望這有幫助。 我知道這不是最好的方法,但是對於像您這樣需要的簡單布局,它應該可以完成工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.