首页 > 解决方案 > 如何在我的应用程序中添加小提示或消息,我应该使用库吗?

问题描述

我是 Android 开发的新手。我正在尝试在我的应用程序中添加新事物。然后我发现 Play Store 上的应用程序看起来很棒。我正在寻找如何添加它,但我找不到答案。

这是图像

标签: androiduser-interfaceuser-experience

解决方案


我手动创建了如图所示的形状。如果你想在你的项目中使用,那么只需使用 layout_background.xml 文件作为布局的背景。

layout_background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke android:color="@color/colorPrimaryDark" android:width="1dp"/>
    <solid android:color="#9308"/>
    <corners android:topLeftRadius="400dp"/>

</shape>

例子.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/layout_background">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentTop="true"
            android:layout_marginEnd="104dp"
            android:layout_marginTop="114dp"
            android:text="Hello World"
            android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />

    </RelativeLayout>


    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="22dp"
        android:layout_marginEnd="18dp" />

</RelativeLayout>

在此处输入图像描述


推荐阅读