简体   繁体   English

我应该如何使此按钮设计在 android 上响应?

[英]How should I make this button design responsive on android?

I've spent the last two days trying to wrap my head around this layout I got asked by the designer to do, the shape is something like:在过去的两天里,我一直在努力思考设计师要求我做的这个布局,形状是这样的:

|         ___         |
|___ ___ /   \ ___ ___|
|btn|btn\\btn//btn|btn|    
|___|____\\_//____|___|

That part of the screen is a button row at the bottom of the screen, the problem comes with responsiveness, if I use an image button on the non square buttons they dont resize properly, adding margins instead of reshaping the image itself, but if I use regular buttons, i lose the cool shapes they ask for.屏幕的那部分是屏幕底部的按钮行,问题在于响应能力,如果我在非方形按钮上使用图像按钮,它们不会正确调整大小,添加边距而不是重塑图像本身,但如果我使用常规按钮,我失去了他们要求的酷形状。 Any ideas/tutorials I could use?我可以使用任何想法/教程吗? Maybe I'm not looking it up as it should be done, but I don't seem to find anything relevant to my problem.也许我没有按应有的方式查找它,但我似乎没有找到与我的问题相关的任何内容。

I have made this with the help of floating action button and the bottom navigation view.Check out given code.我是在浮动操作按钮和底部导航视图的帮助下完成的。查看给定的代码。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/purple_500"
    tools:context=".MainActivity">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/btmbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:backgroundTint="@color/purple_200"
        app:fabCradleMargin="10dp"
        app:fabCradleRoundedCornerRadius="40dp"
        app:fabCradleVerticalOffset="10dp">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:background="@android:color/transparent"
            app:labelVisibilityMode="unlabeled"
            app:menu="@menu/btm_menu" />

    </com.google.android.material.bottomappbar.BottomAppBar>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:alpha="10"
        android:background="@null"
        android:elevation="0dp"
        android:src="@drawable/fire"
        app:backgroundTint="@android:color/transparent"
        app:elevation="0dp"
        app:fabSize="normal"
        app:layout_anchor="@id/btmbar"
        app:tint="@null" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

Output will look like this: Output 将如下所示:

在此处输入图像描述

You can make the changes in below properties to make the space between the bottom app bar.您可以更改以下属性以在底部应用栏之间留出空间。

    app:fabCradleMargin="16dp"

    app:fabCradleRoundedCornerRadius="40dp"

    app:fabCradleVerticalOffset="10dp"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM