简体   繁体   English

如何在动作栏上显示一半的图像

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

I am trying to add a button like in the below picture which is half outside the action bar. 我正在尝试添加一个按钮,如下图所示,该按钮位于操作栏的外面。 I am looking for a standard way to design it as it is so common nowadays. 我正在寻找一种标准的设计方法,因为它现在很普遍。

Thanks 谢谢

在此处输入图片说明

The button is called a Floating action button or "FAB". 该按钮称为浮动动作按钮或“ FAB”。 What you want is a FAB on a CoordinatorLayout. 您想要的是CoordinatorLayout上的FAB。 For further reading you can go here: 要进一步阅读,您可以转到此处:

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

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

You should look for "FloatingActionButton". 您应该寻找“ FloatingActionButton”。

For example: 例如:

<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