How to Make Custom Shaped Layout in Android

ε祈祈猫儿з 提交于 2021-02-06 14:08:41

问题


I'm making a bottom navigation bar, of custom shape Like this =>

So I tried using LinearLayout with a FAB on it, as I dont know much about custom shapes, but my idea not working as, when I scroll my webView bottombar hides, but fab doesn't. Anyways this is a bad method.

So, What I want is to make a custom shaped bottombar, please help me make it, or just simple guiding would be helpful,

Thank you so much :)


回答1:


Create a drawable with the below fields

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="4dp"
        android:left="20dp"
        android:right="20dp"
        android:top="15dp">
        <shape android:shape="rectangle">
            <solid android:color="#ED7D31" /> //Color of youe choice
        </shape>
    </item>

    <item
        android:width="50dp"
        android:height="50dp"
        android:gravity="top|center">
        <shape android:shape="oval">
            <solid android:color="#ED7D31" />

        </shape>
    </item>
</layer-list>

and in the XML file add it as a background like below

<TextView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:elevation="4dp"
    android:background="@drawable/list" /> //Your drawable name here


来源:https://stackoverflow.com/questions/41596264/how-to-make-custom-shaped-layout-in-android

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