安卓開發之實現下角圓形按鈕

來源:互聯網
上載者:User

標籤:

 

 

布局的xml檔案中:

<ImageButton
android:id="@+id/fabButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="bottom|right"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/fab_background"  //圓形背景
android:src="@drawable/ic_favorite_outline_white_24dp"   //圓形上的圖片,自己設定
/>

 

drawable檔案夾下的fab_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<!--drawable/btn_fab_default.xml-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

//設定邊框
<item android:bottom="0dp" android:left="2dp" android:right="2dp" android:top="2dp">
<shape android:shape="oval">
<solid android:color="@color/color_shadow" />
</shape>
</item>

//設定邊框
<item android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp">
<shape android:shape="oval">
<solid android:color="@color/color_primary_red" />
</shape>
</item>
</layer-list>

 

 

values中的color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_primary_red">#f44336</color>
<color name="color_primary_red_dark">#d32f2f</color>
<color name="color_primary_green"> #4caf50</color>
<color name="color_primary_green_dark">#388e3c</color>
<color name="color_shadow">#44000000</color>
</resources>

 

安卓開發之實現下角圓形按鈕

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.