窄屏幕尺寸的宽度变化
width change with narrow screen sizes
我是一名新程序员。我在使用某些屏幕时遇到问题,我的网格 new screen shot 显示为连线行(可能是因为屏幕的宽度很窄)。我已经上传了我的问题和代码的图片。
我哪里做错了?我可以修好它吗?
my problem
<GridLayout
android:id="@+id/gameTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:visibility="invisible">
<!-- the 16 buttons -->
<!-- 1: (0,0) -->
<Button
android:id="@+id/button1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/gridLayout"
android:layout_alignStart="@+id/gridLayout"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_row="0"
android:layout_rowWeight="1"
android:background="@drawable/border"
android:onClick="choosePlace"
android:tag="1"
android:text="1"
android:textSize="20sp" />
为不同的屏幕创建不同的值文件夹,如以下答案所示:
然后在每个dimen.xml
中为按钮写不同的尺寸
<dimen name="btn_width">50dp</dimen>
<dimen name="btn_width">30dp</dimen>
<dimen name="btn_width">20dp</dimen>
然后在你的xml中使用
android:layout_width="@dimen/btn_width"
android:layout_height="@dimen/btn_width"
我是一名新程序员。我在使用某些屏幕时遇到问题,我的网格 new screen shot 显示为连线行(可能是因为屏幕的宽度很窄)。我已经上传了我的问题和代码的图片。 我哪里做错了?我可以修好它吗?
my problem
<GridLayout
android:id="@+id/gameTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal"
android:visibility="invisible">
<!-- the 16 buttons -->
<!-- 1: (0,0) -->
<Button
android:id="@+id/button1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/gridLayout"
android:layout_alignStart="@+id/gridLayout"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_row="0"
android:layout_rowWeight="1"
android:background="@drawable/border"
android:onClick="choosePlace"
android:tag="1"
android:text="1"
android:textSize="20sp" />
为不同的屏幕创建不同的值文件夹,如以下答案所示:
然后在每个dimen.xml
中为按钮写不同的尺寸<dimen name="btn_width">50dp</dimen>
<dimen name="btn_width">30dp</dimen>
<dimen name="btn_width">20dp</dimen>
然后在你的xml中使用
android:layout_width="@dimen/btn_width"
android:layout_height="@dimen/btn_width"