我在Android Studio上使用Nexus模拟器运行我的简单3x3网格类游戏应用程序,一切正常。但是,当我将LG G3插入计算机时,一些按钮堆叠在一起,形成一个2x3网格,而不是我需要的3x3。有没有人知道在手机上运行相同程序的解决方案?谢谢你的帮助。
我使用的布局是相对布局。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|right"
android:background="#ff65b4ff"
android:layout_centerHorizontal="true"
android:id="@+id/activity_game">
<Button
android:layout_width="80dp"
android:layout_height="50dp"
android:text="@string/back"
android:layout_gravity="top|right"
android:id="@+id/back_button"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_unknown_distance_button"
android:layout_gravity="center_horizontal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="432dp"
android:gravity="center">
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/top_center_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/center_button"
android:layout_below="@+id/top_center_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/bottom_center_button"
android:layout_below="@+id/center_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/top_right_button"
android:layout_toRightOf="@+id/top_center_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/right_button"
android:layout_toRightOf="@+id/center_button"
android:layout_below="@+id/top_right_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/bottom_right_button"
android:layout_toRightOf="@+id/bottom_center_button"
android:layout_below="@+id/right_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/top_left_button"
android:layout_toLeftOf="@+id/top_center_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/left_button"
android:layout_toLeftOf="@+id/center_button"
android:layout_below="@+id/top_left_button"
android:layout_margin="5dp"/>
<Button
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/bottom_left_button"
android:layout_toLeftOf="@+id/bottom_center_button"
android:layout_below="@+id/right_button"
android:layout_margin="5dp"/>
</RelativeLayout>