如何在Android中制作自定义形状的布局 [英] How to Make Custom Shaped Layout in Android

查看:123
本文介绍了如何在Android中制作自定义形状的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作自定义形状的底部导航栏像这样=>

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

因此,我尝试将LinearLayout与FAB结合使用,因为我对自定义形状的了解不多,但是我的想法不起作用,当我滚动我的webView底部栏时,它隐藏了,但是晶圆厂却没有.无论如何,这是一种不好的方法.

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,

非常感谢您:)

推荐答案

使用以下字段创建可绘制对象

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>

,然后在XML文件中,将其添加为如下所示的背景

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

这篇关于如何在Android中制作自定义形状的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆