Android開發(fā)實(shí)現(xiàn)的圓角按鈕、文字陰影按鈕效果示例
本文實(shí)例講述了Android開發(fā)實(shí)現(xiàn)的圓角按鈕、文字陰影按鈕效果。分享給大家供大家參考,具體如下:
效果圖:
如果要實(shí)現(xiàn)圓角圖片,并變色須在drawable中配置背景文件如下:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 圓角深紅色按鈕 --> <solid android:color="@color/RED"/> <corners android:radius="15dip"/> </shape> </item> <item android:state_pressed="false"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 圓角紅色按鈕 --> <solid android:color="@color/PURPLE"/> <corners android:radius="15dip"/> </shape> </item> </selector>
三個(gè)按鈕整體布局文件:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--文字帶陰影的按鈕--> <!--陰影模糊程度:android:shadowRadius="5"--> <!--陰影與文字的距離:android:shadowDx="20"--> <!--android:shadowDy="20"--> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="文字帶陰影的按鈕" android:textSize="20pt" android:shadowColor="#aa5" android:shadowRadius="5" android:shadowDx="20" android:shadowDy="20"/> <!--普通文字按鈕--> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#836622" android:text="普通按鈕" android:textSize="20pt"/> <!--帶文字的圖片按鈕--> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_selector" android:textSize="20px" android:text="帶文字的按鈕"/> </LinearLayout>
顏色RED和PURPLE的宏定義:
<color name="RED" >#ff0000</color> <color name="PURPLE" >#9a32cd</color>
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android控件用法總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》及《Android資源操作技巧匯總》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
android實(shí)現(xiàn)倒計(jì)時(shí)功能代碼
實(shí)現(xiàn)倒計(jì)時(shí)每隔1秒,變換一下時(shí)間,截圖如下,感興趣的朋友想看下實(shí)現(xiàn)代碼,希望對(duì)你學(xué)習(xí)有所幫助2013-06-06Android之ListView分頁加載數(shù)據(jù)功能實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了Android之ListView分頁加載數(shù)據(jù)功能實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-08-08Android Toolbar自定義標(biāo)題標(biāo)題居中的實(shí)例代碼
這篇文章主要介紹了Android Toolbar自定義標(biāo)題 標(biāo)題居中的實(shí)例代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-08-08Android?Banner本地和網(wǎng)絡(luò)輪播圖使用介紹
大家好,本篇文章講的是Android?Banner本地和網(wǎng)絡(luò)輪播圖使用介紹,感興趣的同學(xué)趕快來看一看吧,希望本篇文章對(duì)你起到幫助2021-11-11Android Studio中通過CMake使用NDK并編譯自定義庫和添加預(yù)編譯庫
這篇文章是基于Android Studio 3.01版本的,NDK是R16。本文重點(diǎn)給大家介紹Android Studio中通過CMake使用NDK并編譯自定義庫和添加預(yù)編譯庫的相關(guān)知識(shí),感興趣的朋友一起看看吧2018-01-01Gradle?Build?Cache引發(fā)的Task緩存編譯問題
這篇文章主要為大家介紹了Gradle?Build?Cache引發(fā)的Task緩存編譯問題,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06Android 多線程的實(shí)現(xiàn)方法總結(jié)
這篇文章主要介紹了Android 多線程的實(shí)現(xiàn)方法總結(jié)的相關(guān)資料,這里提供三種方法,幫助大家掌握這部分內(nèi)容,需要的朋友可以參考下2017-08-08Android基于方法池與回調(diào)實(shí)現(xiàn)登錄攔截的場景
這篇文章主要為大家介紹了Android基于方法池與回調(diào)實(shí)現(xiàn)登錄攔截的場景詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08Android RecyclerView詳解之實(shí)現(xiàn) ListView GridView瀑布流效果
RecyclerView 是Android L版本中新添加的一個(gè)用來取代ListView的SDK,它的靈活性與可替代性比listview更好2016-07-07Android實(shí)現(xiàn)ViewPage輪播圖效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)ViewPage輪播圖效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03