android - 如何android Z顺序?

标签 android android-layout android-framelayout

在我的应用程序中,我想在背景图片上绘图。我有以下 xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg2"
>
    <com.myapp.drawings.DrawingSurface
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/drawingSurface"
    />
    <LinearLayout
            android:orientation="horizontal"
            android:background="@drawable/bg2" 
            android:layout_width="match_parent" 
            android:layout_height="match_parent">
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="OK"
                android:onClick="onClick"
                android:id="@+id/colorBlueBtn"
        />
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="Save"
                android:onClick="onClick"
                android:id="@+id/saveBtn"
        />
    </LinearLayout>
</FrameLayout>

不,问题是,当我尝试在绘图表面上绘图时,我的绘图没有显示。显示了背景图像和按钮。一旦我保存了它,就会显示我的应用程序生成的图像文件。我认为问题出在布局的 Z 顺序上。

有什么想法吗?谢谢你的帮助! :)

最佳答案

首先出现在xml中的项目将首先被绘制。所以你的表面 View 在你的线性布局之下。

关于android - 如何android Z顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7481183/

相关文章:

android - 如何使用带有 fragment 的 Firebase 电子邮件登录?

java - “调用需要 API 级别 23”错误,但 API 1 的 FrameLayout 上存在 getForeground()

java - 如何在 fragment 中显示相机?

android - 按钮数组onclicklistener

android - 获取 fragment 动态附加到 <FrameLayout>?

android - 我应该针对最新的 SDK 编译我的 Android 应用程序吗?

android - 仅具有上下文的导航架构组件导航

java - 如何使用共享首选项将所有地址值存储在单个键中

java - 如何使用Factual API Android驱动程序?

android - 平铺背景正在插入它的 View 大小