Android實(shí)現(xiàn)水波紋點(diǎn)擊效果
Android實(shí)現(xiàn)水波紋點(diǎn)擊效果只在Android5.0以上版本有效,水波紋點(diǎn)擊效果代碼供大家參考,具體內(nèi)容如下
圓角背景的水波紋效果(如上圖)
1. 定義一個(gè)普通圓角背景的xml;
rounded_corners.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFF" /> <corners android:radius="4dp" /> </shape>
2. 這里是重點(diǎn),<ripple>是API21才有的新Tag,正是實(shí)現(xiàn)水波紋效果的;
其中<ripple Android:color="#FF21272B" .... />這個(gè)是指定水波紋的顏色,而<item />里面的東西,我們都很熟悉,就是普通的定義一個(gè)帶圓角的背景。
ripple_bg.xml:
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#FF21272B"> <item> <shape android:shape="rectangle"> <solid android:color="#FFFFFF" /> <corners android:radius="4dp" /> </shape> </item> <item android:drawable="@drawable/rounded_corners" /> </ripple>
3. 這是Activity的布局xml;
<Button android:background="@drawable/ripple_bg"... />直接使用ripple_bg作為背景。
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/ripple_bg" android:text="@string/hello_world" /> </LinearLayout>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android自定義View控件實(shí)現(xiàn)多種水波紋漣漪擴(kuò)散效果
- Android實(shí)現(xiàn)點(diǎn)擊Button產(chǎn)生水波紋效果
- Android特效之水波紋的實(shí)現(xiàn)
- Android仿水波紋流量球進(jìn)度條控制器
- Android實(shí)現(xiàn)水波紋效果
- Android自定義View 實(shí)現(xiàn)水波紋動(dòng)畫引導(dǎo)效果
- Android實(shí)現(xiàn)自定義華麗的水波紋效果
- Android自定義WaveProgressView實(shí)現(xiàn)水波紋加載需求
- Android實(shí)現(xiàn)水波紋外擴(kuò)效果的實(shí)例代碼
- Android實(shí)現(xiàn)水波紋擴(kuò)散效果的實(shí)例代碼
相關(guān)文章
Android筆記之:深入為從右向左語言定義復(fù)雜字串的詳解
本篇文章是對(duì)Android中為從右向左語言定義復(fù)雜字串進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05EditText實(shí)現(xiàn)輸入限制和校驗(yàn)功能實(shí)例代碼
本文通過實(shí)例代碼給大家介紹EditText實(shí)現(xiàn)輸入限制和校驗(yàn)功能,感興趣的朋友參考下吧2017-08-08Android 代碼一鍵實(shí)現(xiàn)銀行卡綁定功能
這篇文章主要介紹了Android 代碼一鍵實(shí)現(xiàn)銀行卡綁定功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04Android自定義控件實(shí)現(xiàn)望遠(yuǎn)鏡效果
這篇文章主要為大家詳細(xì)介紹了Android自定義控件實(shí)現(xiàn)望遠(yuǎn)鏡效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11Android中WebView與Js交互的實(shí)現(xiàn)方法
本文給大家介紹android中webview與js交互的實(shí)現(xiàn)方法,本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)2016-05-05Flutter移動(dòng)端進(jìn)行多渠道打包發(fā)布的全過程
在使用flutter開發(fā)的過程中,需要根據(jù)不同的環(huán)境,不同的包名來打包,下面這篇文章主要給大家介紹了關(guān)于Flutter移動(dòng)端進(jìn)行多渠道打包發(fā)布的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-06-06Android中 TeaScreenPopupWindow多類型篩選彈框功能的實(shí)例代碼
這篇文章主要介紹了Android TeaScreenPopupWindow多類型篩選彈框功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2019-06-06