我在做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 –