gpt4 book ai didi

java - 创建自定义搜索栏

转载 作者:行者123 更新时间:2023-12-01 15:43:30 27 4
gpt4 key购买 nike

我想向我的 Activity 添加一个搜索栏,应如下所示:

enter image description here

我的 Layout.xml 如下所示:

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

<LinearLayout android:orientation="horizontal"
style="@android:style/ButtonBar" android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<EditText android:id="@+id/ean" android:layout_width="100dp"
android:layout_height="fill_parent" android:layout_weight="1.5"/>
<Button android:id="@+id/search" android:layout_width="0.0dip"
android:layout_height="fill_parent" android:text="@string/Search"
android:layout_weight="1.0" />
</LinearLayout>

<LinearLayout android:orientation="horizontal"
style="@android:style/ButtonBar" android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button android:id="@+id/cancel" android:layout_width="0.0dip"
android:layout_height="fill_parent" android:text="@string/cancel"
android:layout_weight="1.0" />
<Button android:id="@+id/light" android:layout_width="0.0dip"
android:layout_height="fill_parent" android:text="@string/light"
android:layout_weight="1.0" />
</LinearLayout>

图形布局如下所示: enter image description here

如何设计我的布局,如上图所示?

最佳答案

我尝试用 ImageButton 替换 Button。然后,我为按钮和文本框创建 9patch 图像,并使用样式分配它们。

关于java - 创建自定义搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7598025/

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