繁体   English   中英

创建自定义搜索栏

[英]Create Custom Search Bar

我想在我的活动中添加一个看起来像这样的搜索栏:

在此处输入图片说明

我的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>

图形布局看起来像这样: 在此处输入图片说明

如何设置上图中的布局样式?

我想尝试并更换ButtonImageButton 然后,我将为按钮和文本框创建9patch图像,并使用样式进行分配。

只是一无所有。 只需在具有该特定背景的xml布局文件中设计主题,然后根据您的设计添加一个editText和按钮,然后按活动访问即可。

如果需要进一步的帮助,请评论我。

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM