Android 使用<layer-list>實(shí)現(xiàn)微信聊天輸入框功能
LayerDrawable
<layer-list> 標(biāo)簽可是設(shè)置LayerDrawable,一種有層次的Drawable疊加效果,<layer-list> 可以包含多個(gè) <item>標(biāo)簽,
每個(gè) <item>代表一個(gè)Drawable。<item>可以通過left、right、top、bottom設(shè)置左右上下的偏移量,<item>可以應(yīng)用一個(gè)圖片,也可以是一個(gè)shape
我們來模仿實(shí)現(xiàn)微信的聊天輸入框:
先設(shè)置綠色的背景:
<?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="@android:color/holo_green_light" />
</shape>
</item>
</layer-list>

再疊加一層白色,留出側(cè)面綠色線條的高度:
<?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="@android:color/holo_green_light" />
</shape>
</item>
<item android:bottom="8dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>

再鋪上一層白色,覆蓋已經(jīng)設(shè)置好的背景,留出底部和側(cè)面的線條,中間的一層其實(shí)就是為了留出兩邊的綠色線框的高度:
<?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="@android:color/holo_green_light" />
</shape>
</item>
<item android:bottom="8dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:shape="rectangle">
<shape>
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
以上所述是小編給大家介紹的Android 使用<layer-list>實(shí)現(xiàn)微信聊天輸入框,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- Android實(shí)現(xiàn)微信右側(cè)頂部下拉對話框
- Android仿微信和QQ多圖合并框架(類似群頭像)的實(shí)現(xiàn)方法
- android仿支付寶、微信密碼輸入框效果
- Android 類似微信登錄輸入框效果
- Android 仿微信朋友圈點(diǎn)贊和評論彈出框功能
- Android仿QQ、微信聊天界面長按提示框效果
- Android中自定義對話框(Dialog)的實(shí)例代碼
- Android實(shí)現(xiàn)點(diǎn)擊AlertDialog上按鈕時(shí)不關(guān)閉對話框的方法
- Android中AlertDialog各種對話框的用法實(shí)例詳解
- Android開發(fā)實(shí)現(xiàn)模仿微信小窗口功能【Dialog對話框風(fēng)格窗口】
相關(guān)文章
Android編程使用Service實(shí)現(xiàn)Notification定時(shí)發(fā)送功能示例
這篇文章主要介紹了Android編程使用Service實(shí)現(xiàn)Notification定時(shí)發(fā)送功能,涉及Android服務(wù)Service控制通知的發(fā)送功能相關(guān)操作技巧,需要的朋友可以參考下2017-08-08
詳解Android的OkHttp包編寫異步HTTP請求調(diào)用的方法
OkHttp支持Callback異步回調(diào)來實(shí)現(xiàn)線程的非阻塞,下面我們就來詳解Android的OkHttp包編寫異步HTTP請求調(diào)用的方法,需要的朋友可以參考下2016-07-07
Android 重寫ViewGroup 分析onMeasure()和onLayout()方法
這篇文章主要介紹了Android 重寫ViewGroup 分析onMeasure()和onLayout()方法的相關(guān)資料,需要的朋友可以參考下2017-06-06
Android編程經(jīng)典代碼集錦(復(fù)制,粘貼,瀏覽器調(diào)用,Toast顯示,自定義Dialog等)
這篇文章主要介紹了Android編程經(jīng)典代碼集錦,包括Android的復(fù)制,粘貼,瀏覽器調(diào)用,Toast顯示,自定義Dialog等實(shí)現(xiàn)技巧,非常簡單實(shí)用,需要的朋友可以參考下2016-01-01
Android使用ViewPager實(shí)現(xiàn)類似laucher左右拖動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Android使用ViewPager實(shí)現(xiàn)類似laucher左右拖動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
Android中AsyncTask的入門使用學(xué)習(xí)指南
AsyncTask異步任務(wù),用于執(zhí)行耗時(shí)任務(wù)并在UI線程中更新結(jié)果。下面這篇文章主要給大家介紹了關(guān)于Android中AsyncTask入門使用的相關(guān)資料,需要的朋友可以參考下2019-02-02
解析android創(chuàng)建快捷方式會啟動(dòng)兩個(gè)應(yīng)用的問題
本篇文章是對關(guān)于android創(chuàng)建快捷方式會啟動(dòng)兩個(gè)應(yīng)用的問題進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

