-1

我很好奇如何在我的应用程序中添加一种类似于附加图像的教程功能,其中似乎应用程序顶部有一个层(在这种情况下是主屏幕)。安卓模拟器截图

4

2 回答 2

0

要在视图之上创建一个层,您可以在 RelativeLayout 或 FrameLayout 中创建主视图,然后向主视图添加一个可以是 RelativeLayout 或 LinearLayout 的新视图,并将新视图的背景设置为 alpha black ( <color name="alphablack">#80000000</color>),这是一个代码示例:

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

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center"
                android:text="HELLO WORLD!"/>

          <RelativeLayout 
               android:id="@+id/rlLayer"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:background="@color/alphablack"
               android:visibility="gone">
          </RelativeLayout>
    </RelativeLayout>

首先将图层的可见性设置为消失,如果要显示图层,可以使用 view.setVisibility(View.VISIBLE) 设置可见性,教程完成后可以使用 view.setVisibility(View.GONE 将其关闭)。我希望我的回答可以帮助你,但如果你对我的回答有其他问题,请随时在评论中提问:)

于 2013-06-02T15:50:08.520 回答
0

使用https://github.com/Espiandev/ShowcaseView它完全按照您在屏幕截图中显示的内容进行操作。

于 2013-06-02T15:42:48.967 回答