gpt4 book ai didi

android - 在 LinearLayout 中如何将 EditText 放在按钮上?

转载 作者:行者123 更新时间:2023-11-29 19:30:04 29 4
gpt4 key购买 nike

这是现在的样子:

enter image description here

我希望它看起来像什么:

enter image description here

我想在按钮(时间流逝的地方)内有一个可编辑的文本框。我该怎么做?

代码:

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

// NAME 1
<Button
android:id="@+id/name1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/button_border"
android:text="Name"
android:onClick="changeName"/>
// NAME 2
<Button
android:id="@+id/name2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/button_border"
android:text="NAME"
android:onClick="changeName"/>

</LinearLayout>

谢谢,对于问题的简单性,我们深表歉意。我只是一个业余爱好者,想了解更多。

最佳答案

试试这个方法对你有帮助

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


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:background="#4472C4"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Liam Ten"
android:textStyle="bold"

android:textColor="@android:color/white"
android:textSize="16dp"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="01:03:66"
android:textSize="16dp"
android:textColorHint="@android:color/white"

/>
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Neil C"
android:textSize="16dp"
android:gravity="center"
android:background="#4472C4"

android:textColor="@android:color/white"
android:layout_weight="1"
android:textStyle="bold"
/>
</LinearLayout>
</LinearLayout>

输出

enter image description here

关于android - 在 LinearLayout 中如何将 EditText 放在按钮上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40232056/

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