我在做Android Studio中一個有趣的井字應用程序,有一個問題。如果我nexus5x使用預覽在佈局編輯器我的應用程序是面向perfect.If我改變這nexus4或一個平板電腦的方向是搞砸了。 這是我的意思的圖片。 Nexus 5x as preview和Nexus 4 as preview級圖像工作室
從我的XML代碼的示例是如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mpampis.tictactoe2.MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:background="@drawable/board"
android:columnCount="3"
android:rowCount="4">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
android:layout_row="0"
android:layout_column="2"
android:src="@drawable/kokkinov3"
android:layout_marginTop="25dp"
android:layout_marginLeft="20dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:layout_row="0"
android:layout_column="1"
android:src="@drawable/kokkinov3"
android:layout_marginTop="25dp"
android:layout_marginLeft="30dp"/>
您是否正在做任何事情來縮放您的圖像以適應運行時在網格中可用的空間量? –
我在drawables中有一個.png文件,當我在GridLayout中使用它時,我將它放在邊緣的位置來定位它。 – oMpamparos
有時您需要爲每個res創建xml。 RES /佈局/ main_activity.xml#針對手機(小於600dp的可用寬度) RES /佈局sw600dp/main_activity.xml#針對7」 片劑(寬度爲600 dp和更大) RES /佈局sw720dp/main_activity.xml#針對10「平板電腦(720dp寬和更大) - http://developer.android.com/guide/practices/screens_support.html –