android - 屏幕外的按钮 - Android
问题描述
我需要帮助...
我试图在buttons
a 内构建 3 个对齐的 1 行和 3 列GridLayout
,并且看起来它可以正常工作,但我认为我没有做对,因为如果更改按钮 ( textSize
)GridLayout
和按钮内的文本大小正在走出屏幕。我认为我设置了layout_witdh
和/或layout_height
错误,但我不确定。
谁能帮我?谢谢 :)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/background"
tools:context="com.markus.tssproject.MainActivity">
<RelativeLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:columnCount="3"
android:rowCount="1">
<Button
android:id="@+id/id0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_marginRight="3dp"
android:layout_row="0"
android:layout_rowWeight="1"
android:padding="30dp"
android:tag="0"
android:text="test tested testing"
android:textSize="20sp" />
<Button
android:id="@+id/open1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_column="1"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_row="0"
android:layout_rowWeight="1"
android:padding="30dp"
android:tag="1"
android:text="test tested testing"
android:texSize="20sp" />
<Button
android:id="@+id/open2"
android:layout_width="wrap_content"
android:layout_column="2"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_row="0"
android:layout_rowWeight="1"
android:padding="30dp"
android:tag="2"
android:text="teste tested testing"/>
</GridLayout>
</RelativeLayout>
</LinearLayout>
解决方案
在每个按钮中更改以下内容
android:layout_width="0dip"
android:layout_weight ="1"
你可以自己做LinearLayout
,不需要网格布局
推荐阅读
- dart - 动态生成导航按钮
- c - 使用自定义前缀创建 printf 函数
- c++ - C++ 需要一种很好的技术来播种不使用 time() 的 rand()
- javascript - Node JS 中的地图操作
- java - 在 Spring Boot 中限制每 t 请求
- apache-spark - YARN 关闭 Pyspark write.csv() 以超出内存限制
- android - 尝试在 Android 上使用 FlexibleAdapter
- java - 请不使用数组的java字符串中字符的最大出现次数
- actionscript-3 - Adobe Animate Actionscript 3.0“clicktogotonextscene”代码不起作用
- c# - 在发布配置中运行时,我应该在 Visual Studio 的输出窗口中看到调试输出吗?