在我的应用程序中,我想在背景图片上绘图。我有以下 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/