android开发之仿微信输入框效果

本文介绍如何在Android应用中实现类似微信输入框的效果。通过使用LayerList,分三层设计:底层为绿色背景,第二层形成文本框两侧的小勾视觉效果,第三层则在四周留出适当距离,营造出输入框的立体感。
  • 仿微信输入框效果图:
    这里写图片描述

  • 输入框:

<EditText
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_marginLeft="50dp"
     android:layout_marginRight="50dp"
     android:background="@drawable/weixin_edittext"
     android:layout_alignParentBottom="true"
     android:layout_marginBottom="6dp"
     android:paddingLeft="5dp"
     android:paddingRight="30dp"
     android:textColor="#000000"/>
  • background:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#0ac39e" />
        </shape>
    </item>

    <item android:bottom="6dp">
        <shape android:shape="rectangle" >
            <solid android:color="#ffffff" />
        </shape>
    </item>

    <item
            android:bottom="1dp"
            android:left="1dp"
            android:right="1dp">
        <shape android:shape="rectangle" >
            <solid android:color="#ffffff" />
        </shape>
    </item>

</layer-list> 
  • 思路:
    采用LayerList来实现,分三层实现,这里假设activity的背景是白色,第一层也(就是最底层)是绿色;第二次是白色,但是距离底部有一段小偏移,目的是为了做出文本框两边的小勾;第三层也是白色,但是它距离底部和左右两边都有一定距离。通过三层配合,即可实现这种效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值