[英]width change with narrow screen sizes
I am a new programmer. 我是新来的程序员。 I having trouble with some of the screens my grid new screen shot appears as wired rows (maybe because the width of the screen is narrow ) .
我在使用某些屏幕时遇到麻烦,我的新屏幕快照显示为有线行(可能是因为屏幕的宽度很窄)。 I've uploaded picture of my problem and my code.
我已经上传了我的问题和代码的图片。 where did I go wrong?
我哪里做错了? hw can I fix it?
可以解决吗?
<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" />
Create Different values folder for different screens as in following answer: How to define dimens.xml for every different screen size in android? 为不同的屏幕创建不同的值文件夹,如以下答案: 如何在Android中为每个不同的屏幕尺寸定义dimens.xml?
Then write different sizes for buttons in each dimen.xml 然后在每个dimen.xml中为按钮编写不同的大小
<dimen name="btn_width">50dp</dimen>
<dimen name="btn_width">30dp</dimen>
<dimen name="btn_width">20dp</dimen>
And then in your xml use 然后在您的xml中使用
android:layout_width="@dimen/btn_width"
android:layout_height="@dimen/btn_width"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.