温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android中设置搜素联系人的布局

发布时间:2020-08-14 04:16:22 来源:网络 阅读:614 作者:南京小帅 栏目:移动开发

我们现在要达到下面的效果:

Android中设置搜素联系人的布局

我们这样做了:我们可以先定义一个线性布局:

在线性布局中加入一个ImageView和一个Edittext

最后给这个线性布局加入背景,该背景就是外面的一个灰色边框。

我们来看看代码:

 <LinearLayout
            android:id="@+id/RelativeLayout1"
            android:layout_width="250dp"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/roud_edit"
            android:focusable="true"

            android:focusableInTouchMode="true"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_marginLeft="3dp"
            android:layout_marginBottom="2dp" >
            <ImageView
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:src="@drawable/search2"/>

            <EditText
                android:id="@+id/contactfind_text"
                android:layout_width="200dp"
                android:layout_height="fill_parent"
                android:layout_gravity="center_horizontal"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center_vertical"
                android:hint="请输入搜素联系人"
                android:paddingLeft="15dip"
                android:paddingRight="10dip"
                android:singleLine="true"
                android:textSize="20sp"
                />


        </LinearLayout>

android:background="@drawable/roud_edit"

这就是我们给线性布局添加的背景,我们来看如何实现

在:F:\voip_20141118\voip\res\drawable文件下建立

roud_edit.xml
里面代码如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#00000000"/>
    <corners android:radius="8px"/>
    <stroke android:color="#33000000"
        android:width="2px"
        />
</shape>

其中:

xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 背景色 -->
<solid android:color="#FFE4B5"/>
<!-- 边框色 -->
<stroke android:width="0.5dip" android:color="#81CE47" />
</shape>

http://www.xuebuyuan.com/38114.html

http://blog.csdn.net/ma12an/article/details/7758464


对应EDITText有下面一种属性:也是比较常使用的:

http://xinmiao520169.blog.163.com/blog/static/205251258201302143933663/

好好的看看。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI