如何在BottomBar布局android中添加中间按钮 [英] How to add the middle Button in BottomBar layout android
问题描述
我想在我的底栏布局中间添加超级按钮等facebook Messenger,但又混淆了如何添加..
我使用ahbottomnavigation库制作我的底栏。
我只是试图使它变得简单,而不是专业类型。看这里:
BottomSheetLayout文件 - tv.xml
:
<?xml version =1.0encoding =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.0encoding =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>
输出:
根据您的想法更改价值和设计。
示例只是一个演示,不包含OP提出的确切答案。它只是一个硬编码的假人。
I want to add facebook messenger like oversized button in the middle of my bottombar layout but confused how to add..
I was using ahbottomnavigation library for making my bottombar.
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.
这篇关于如何在BottomBar布局android中添加中间按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!