欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android開發(fā)實現(xiàn)的圓角按鈕、文字陰影按鈕效果示例

 更新時間:2019年04月05日 14:23:54   作者:水中魚之1999  
這篇文章主要介紹了Android開發(fā)實現(xiàn)的圓角按鈕、文字陰影按鈕效果,涉及Android界面布局與屬性設置相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Android開發(fā)實現(xiàn)的圓角按鈕、文字陰影按鈕效果。分享給大家供大家參考,具體如下:

效果圖:

如果要實現(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>

三個按鈕整體布局文件:

<?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ā)入門與進階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》及《Android資源操作技巧匯總

希望本文所述對大家Android程序設計有所幫助。

相關(guān)文章

最新評論