How to add the middle Button in BottomBar layout android

☆樱花仙子☆ 提交于 2019-12-21 18:04:52

问题


I want to add facebook messenger like oversized button in the middle of my bottombar layout but confused how to add..

Facebook Messenger

I was using ahbottomnavigation library for making my bottombar.


回答1:


I just tried to make it simple, not professional type. Look here:

BottomSheetLayout file - tv.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:bottom="2dp"
    android:left="2dp"
    android:right="2dp"
    android:top="15dp">
    <shape android:shape="rectangle">
        <solid android:color="@color/colorPrimary" />
    </shape>
</item>

<item
    android:width="70dp"
    android:height="70dp"
    android:gravity="top|center">
    <shape android:shape="oval">
        <solid android:color="@color/colorPrimaryDark" />

    </shape>
</item>

ActivityLayout - activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
    android:layout_height="80dp"
    android:layout_width="match_parent"
    android:background="@drawable/tv"
    android:gravity="bottom"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:id="@+id/view">

</RelativeLayout>

<ImageButton
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginStart="34dp"
    android:layout_alignBottom="@+id/imageButton"
    android:layout_toEndOf="@+id/imageButton"
    android:id="@+id/imageButton3" />

<ImageButton
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:background="@drawable/ic_ring"
    android:layout_alignTop="@+id/view"
    android:layout_centerHorizontal="true"
    android:id="@+id/imageButton" />

<ImageButton
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginStart="33dp"
    android:id="@+id/imageButton2"
    android:layout_alignBottom="@+id/imageButton3"
    android:layout_toEndOf="@+id/imageButton3" />

<ImageButton
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:id="@+id/imageButton4"
    android:layout_marginEnd="34dp"
    android:layout_alignBottom="@+id/imageButton"
    android:layout_toStartOf="@+id/imageButton" />

<ImageButton
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:id="@+id/imageButton5"
    android:layout_alignParentBottom="true"
    android:layout_toStartOf="@+id/imageButton4"
    android:layout_marginEnd="33dp"
    android:layout_marginBottom="10dp"/>

</RelativeLayout>

Output:

Change value and design as per your idea.

Example is just a demo and does not contain exact answer asked by OP. Its just a hard coded dummy.



来源:https://stackoverflow.com/questions/41673371/how-to-add-the-middle-button-in-bottombar-layout-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!