[英]Android layout for Nexus4 vs Nexus 7
我在Nexus 4中預覽我的Android應用程序。 這里是
但是當我嘗試在Nexus 7模擬器上預覽時,:(
我認為我在游戲中支持多個屏幕時遇到了問題。 我的問題是,如何讓它在nexus 7或10或任何其他設備上看起來更大?
順便說一句,我把我的圖像(board.png,small_hole.png,big_hole.png和bg.png)放在drawable-xhdpi文件夾上(我正在使用Android Studio)
您認為我在xml文件中使用了錯誤的布局或屬性嗎? 我的代碼中有什么問題嗎?
這是我的xml布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg.png>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/board"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/big_hole" >
</ImageView>
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="2dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/small_hole" >
</ImageView>
// paste 6 more ImageViews here
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="7dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/small_hole" >
</ImageView>
// paste 6 more ImageViews here
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:background="@drawable/big_hole" >
</ImageView>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
感謝大伙們..
嘗試將你的圖像放在res / mdpi中它們將被拉伸以適應更大的屏幕(hdpi,xhdpi)(如果我沒記錯的話,modyfiers是x1.5而x2是hdpi和xhdpi)。
另外,您可以為更大的屏幕制作布局文件夾,即。 layout-sw720dp並在那里創建一個新的布局文件。
Nexus 4訪問drawable-xhdpi
資源和
Nexus 7訪問drawable-large-tvdpi
或drawable-sw600dp-tvdpi
資源。
Nexus 10訪問drawable-xlarge-xhdpi
或drawable-sw720dp-xhdpi
資源。
你應該調整你的圖像大小,並把你的shud放在各自的文件夾中。
Nexus 4尺寸為4.7英寸(768 * 1280),Nexus 7尺寸為7英寸(800 * 1280)。
更多信息:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.