簡體   English   中英

如何在動作欄上顯示一半的圖像

[英]How to display an image on action bar that is half outside

我正在嘗試添加一個按鈕,如下圖所示,該按鈕位於操作欄的外面。 我正在尋找一種標准的設計方法,因為它現在很普遍。

謝謝

在此處輸入圖片說明

該按鈕稱為浮動動作按鈕或“ FAB”。 您想要的是CoordinatorLayout上的FAB。 要進一步閱讀,您可以轉到此處:

https://material.google.com/components/buttons-floating-action-button.html#buttons-floating-action-button-large-screens

https://guides.codepath.com/android/floating-action-buttons

您應該尋找“ FloatingActionButton”。

例如:

<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/viewA"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.15">

            </LinearLayout>

        <LinearLayout
            android:id="@+id/viewB"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.85" >

        </LinearLayout>

    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/btn_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/activity_horizontal_margin"
        android:clickable="true"
        android:src="@drawable/ic_ok"
        app:layout_anchor="@id/viewA"
        app:layout_anchorGravity="left|bottom"
        app:backgroundTint="@color/accent"/>

</android.support.design.widget.CoordinatorLayout>

暫無
暫無

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

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