gpt4 book ai didi

android - 我如何创建一个带有下面 TextView 的按钮网格

转载 作者:太空狗 更新时间:2023-10-29 16:19:06 25 4
gpt4 key购买 nike

enter image description here

你好,

我想创建一个像我(尝试)在上面绘制的屏幕。A,b,c,d,e,f,g 和 h 是 buttons,p 是 EditText

现在我想要完成的是,当部署在更大或更小的屏幕上,或者旋转时,会发生以下情况:

  • 元素 'p' 保持相同的高度但水平调整大小(获取更宽/更小)
  • 元素 a-h(按钮)都是水平大小和垂直。所以当屏幕变宽两倍时,按钮是两倍宽,当它两倍高时,按钮是两倍一样高。

我已经能够创建一行按钮以水平调整大小(使用 lineairlayoutandroid:layout_weight,但我没有进一步。

最佳答案

尝试一下,希望它有效:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>

<EditText
android:layout_width="match_parent"
android:layout_height="50dp" />

</LinearLayout>

关于android - 我如何创建一个带有下面 TextView 的按钮网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20081317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com