为什么framelayout无法正确绘制z索引? [英] Why is the framelayout not drawing z index correctly?

查看:126
本文介绍了为什么framelayout无法正确绘制z索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是完整的XML android布局文件代码:

Here is the full XML android layout file code:

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

<Button
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="New Button"
    android:textAllCaps="false"
    android:textSize="15pt"
    android:id="@+id/element_button"
    android:layout_gravity="center" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/element_number"
    android:layout_gravity="top|left" />
</FrameLayout>

它会在android Studio预览窗口以及设备上生成此代码:

It produces this in the android Studio preview window as well as on the device:

我输了吗?是什么赋予了?如您所见,"New Text"文本视图位于按钮后面.在每个代码示例中,我都在stackoverflow上找到了代码,并在简单的编程逻辑中,首先绘制了按钮,然后绘制了TextView,因此,textview位于按钮上方.但事实并非如此. RelativeLayout也会发生这种情况.

Am I losing it? What gives? As you can see, the "New Text" text view is BEHIND the button. When in every code sample I found on stackoverflow, and in simple programming logic, the button gets drawn FIRST, THEN the TextView, therefore, textview is on top of button. But its not. This happens with the RelativeLayout as well.

推荐答案

您不会发疯,这是您的样式中的主题:

You're not crazy it's the theme in your Styles that is doing it:

将进行疯狂的订购:

  <style name="AppTheme" parent="android:Theme.AppCompat">

将恢复您的理智:

  <style name="AppTheme" parent="android:Theme.Holo">

为什么这样做呢……也许是错误,也许是变化,对不起,我不确定

WHY it's doing it ... maybe a bug, maybe a change, sorry I'm not sure

您可以在此处尝试各种主题来证明这一点:

You can play around with the themes here to prove it:

vs

这篇关于为什么framelayout无法正确绘制z索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆