【问题标题】:Create a full screen view over the other在另一个之上创建一个全屏视图
【发布时间】:2018-11-06 16:20:11
【问题描述】:

我正在创建一个 Android 应用程序。

当我点击一个菜单项时,我需要打开一个活动/视图/片段(我不知道什么是最好的)。此活动/片段/视图需要放置为我的应用程序的“覆盖”(它将具有透明背景,我们可以看到后面的“常规”活动)。

我在我的应用程序中使用了一个导航抽屉和几个片段。

首先我尝试了这个:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
    tools:context=".AlertActivity"
    android:id="@+id/alertLayoutRoot"
    android:background="@android:color/transparent"
    >

    <TextView
        android:layout_width="match_parent"
        android:id="@+id/editText1"
        android:text="@string/mes_favoris"
        android:layout_height="match_parent"
        >
    </TextView>

</FrameLayout> 

这确实显示了我的片段,但这个片段并不在所有其他片段之上。

最好的方法是什么(与 Kotlin 合作)?

编辑:忘了说,在这个视图中,会有一个小滑块。

基本上我想要这个:Overlay

【问题讨论】:

    标签: android kotlin overlay android-framelayout


    【解决方案1】:

    您可以使用dialog fragment,因为它支持自定义布局,例如片段并显示在另一个活动或片段之上。

    Here 是关于对话框片段的有用教程。

    【讨论】:

    • DialogFragment 正在等待用户选择?我忘了说,在这个视图中,我将显示一个小滑块(不存在“是、否、取消”的可能性)
    • 您可以使用dialog.setOnDismissListener,然后在回调中您可以从对话框中获取结果并继续执行。
    • 你能解释一下吗?
    猜你喜欢
    • 2014-08-14
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    • 2019-03-09
    • 2016-12-19
    相关资源
    最近更新 更多