[英]How would I be able to “cut out” a circular shape for a fab button in my ui background?
I'm trying to achieve the same as what's boxed in the image only I'm a programmer and I'm not sure how to start.我正在尝试实现与图像中装箱相同的内容,只是我是一名程序员,但我不知道如何开始。
Could this be achieved with a drawable?这可以通过drawable来实现吗? If so, would yo be able to point me in the right direction, or is it much more complex and something a graphics designer would need to achieve?如果是这样,您能否为我指明正确的方向,还是它更复杂,图形设计师需要实现的目标?
You can simply do this using the help of Material BottomAppBar along with Floating Action Button(FAB) .您可以使用Material BottomAppBar和Floating Action Button(FAB)的帮助来简单地做到这一点。 You need to simply place both of them under the NestedScrollView
of the layout which is shown below您只需将它们都放在如下所示的布局的NestedScrollView
下
<androidx.coordinatorlayout.widget.CoordinatorLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Note: A RecyclerView can also be used -->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="100dp"
android:clipToPadding="false">
<!-- Scrollable content -->
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
app:navigationIcon="@drawable/ic_menu_24dp"
app:menu="@menu/bottom_app_bar"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_add_24dp"
app:layout_anchor="@id/bottomAppBar"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Set these attributes accordingly to achieve the shape what you want.相应地设置这些属性以实现您想要的形状。 Use fabCradleMargin
and fabCradleRoundedCornerRadius
attributes in BottomAppBar
to set the rounded Corner and margin.使用fabCradleMargin
和fabCradleRoundedCornerRadius
在属性BottomAppBar
设定圆角和保证金。
Kindly refer to the official documentation for more information about implementation.有关实施的更多信息,请参阅官方文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.