简体   繁体   English

屏幕尺寸变窄时宽度变化

[英]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? 可以解决吗?

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" />

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.

相关问题 DialogWhenLarge屏幕宽度太窄 - DialogWhenLarge screen width too narrow 相同宽度dp的不同屏幕尺寸 - different screen sizes with the same width dp 适合所有屏幕尺寸的 Appwidget 最大宽度 - Appwidget Maximum Width that fits all screen sizes 将给定的视图和屏幕宽度行为缩放为不同屏幕尺寸的相同 - Scaling given view and screen width behaviour to be same for different screen sizes 不同屏幕尺寸的最佳方式是什么{屏幕宽度 - 屏幕高度 - 最小屏幕宽度} - What is the best way in different screen sizes {Screen width - Screen Height - Smallest Screen width} 指定视图的高度宽度以支持多种屏幕尺寸? - Specify height width of the view to support multiple screen sizes? 根据不同的屏幕尺寸调整自定义网格项目的高度和宽度 - Adjust the height and width of custom grid item according to different screen sizes 指定cardview的布局宽度以适合所有手机屏幕尺寸 - specify layout width of cardview to fit all phone screen sizes 在不同的屏幕尺寸上以相同的宽高比调整ImageView / ImageButton的大小 - Resize ImageView/ImageButton on different screen sizes with same width and height ratio 如何设置布局宽度以在不同屏幕尺寸下查看相同 - How to set layout width to view the same in different screen sizes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM