簡體   English   中英

如何創建不同形狀的浮動操作按鈕

[英]How can i create a different shape floating action button

我試圖獲得一個浮動操作按鈕,但大小不同,我嘗試了一些鏈接,但沒有一個有效。 任何幫助都會很棒

我嘗試過代碼,並試圖在底部導航視圖上方拍攝圖像視圖。 但是在點擊片段后,它就消失了。

在此處輸入圖片說明

 <com.jediburrell.customfab.FloatingActionButton
        android:id="@+id/floating_action_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        app:fabType="custom"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        app:fabShape="@drawable/fab_teardrop"
        app:fabColor="@color/red" />

我正在嘗試制作一個橢圓形的晶圓廠

下面是工作代碼

橢圓.xml (形狀)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid android:color="@color/colorPrimary" />


</shape>

活動_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="82dp"
        android:layout_height="65dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="16dp"
        android:background="@drawable/oval"
        android:src="@android:drawable/ic_dialog_map"
        app:backgroundTint="@drawable/oval" />
</RelativeLayout>

讓我知道更多幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM