gpt4 book ai didi

android - 对话框中的确定按钮

转载 作者:行者123 更新时间:2023-11-30 03:26:05 26 4
gpt4 key购买 nike

我是 android 的新手,我遇到了 android UI 的问题。我想把 OK 按钮放在对话对话框中的行的边缘。我怎样才能做到这一点。 enter image description here

The xml i am using for now is this.

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

<TextView
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="defedfg"
android:textSize="20sp"/>

<Button
android:id="@+id/dialogButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/blue_button_xhdpi"
android:text="@string/ok"
android:layout_marginTop="30dp"
android:textColor="#f7f6f5"/>


</LinearLayout>

最佳答案

这是非常简单的解决方案。给 Take One Parent Layout 并在里面 Take one LinearLayout 和 One button。然后在 Layout Child 上保留一些边距

这是 XML

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

<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="20dp"
android:background="@android:color/black"
android:padding="10dp" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@android:color/white" >
</LinearLayout>
</LinearLayout>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="OK" />

和输出

enter image description here

关于android - 对话框中的确定按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18233757/

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