Android 搜索框(shape)

公司项目要做一个搜索框,像我这样的小白菜也不行,只能去百度+谷歌,据说有个什么什么搜索控件,看了一下觉得有些麻烦,我觉得一定还有更简单的办法,黄天不负有心,最后终于叫我找到了,整理了一下基本搞定。下面就是贴源码了哈。。。


1,第一要配置一个xml文件,这个文件主要是做框的(shape.xml)我把它放在了drawable目录下。

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke android:width="1dp" android:color="#EAEAEA"/>
<padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
</shape>

2,第二就是创建一个显示布局的xml文件了(search.xml)(注意红色的位置)

<?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:background="@drawable/ll_status_selector" 
    android:orientation="vertical"
    >
 <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/ll_status_selector" 
          android:orientation="horizontal"
        >
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="210dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="10dip"
        android:background="@drawable/shape" 
        >


        <EditText
            android:id="@+id/editTextsearch"
            android:layout_width="40dip"
            android:layout_height="35dip"
            android:layout_weight="1"
            android:textSize="15dip"
            android:singleLine="true"
            android:hint="点击这里输入..."
           
            android:background="#FFFFFF" />


        <Button
              android:id="@+id/searchbutton"
            android:layout_width="wrap_content"
            android:layout_height="35dip"
            android:background="@drawable/edit"
            />
    </LinearLayout>


    <Button
        android:id="@+id/backhbutton"
        android:layout_width="70dip"
        android:layout_height="36dip"
        android:layout_marginTop="10dip"
        android:layout_marginLeft="25dip"
        android:background="#CCCCCC"
        android:textColor="#ffffff"
        android:text="返回" />
    
    </LinearLayout>
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/ll_status_selector" >
         <Button 
               android:layout_width="1333dip"
               android:layout_height="2dip" 
               android:layout_marginTop="5dip"
               android:background="@drawable/abs__tab_selected_holo"
             />
        <ListView 
            android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ll_status_selector"
            />
    </LinearLayout>


</LinearLayout>

             哈哈大功告成了亲们,可以显示在Activity中了!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值