gpt4 book ai didi

android - RelativeLayout zorder Lollipop

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:26 27 4
gpt4 key购买 nike

我有一些布局可以在 API 19: 4.2.2 上正常工作,但不能让它在 API 21: 5.0.1 上工作。

这是布局:

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

<Button
android:id="@+id/start_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="bold"
android:textSize="30sp"
android:background="@color/start_button_bg"
android:textColor="@color/start_button_text"
android:text="@string/start_process"/>

<TextView
android:id="@+id/pro_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:textColor="@android:color/white"
android:background="@drawable/pro_icon"
android:text="PRO"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"/>

</RelativeLayout>

非常简单的东西。我只希望 textview 位于相对布局中的 Button 之上。我知道相对布局按照它们在 xml 中添加的顺序堆叠 View ,但这似乎在 Lollipop 上的工作方式不同。我无法让 TextView 在按钮上呈现。有什么想法吗?

干杯。

最佳答案

默认情况下,Button 在 Android 5.0+ 上有一个 elevationTextView 没有。小部件的高度基本上会覆盖 RelativeLayoutFrameLayout 设置的 Z 轴顺序。

您的选择是:

  1. 重新设计您的 UI,使小部件不在 Z 轴上排序,或者

  2. Replace the StateListAnimator on your Button to modify or eliminate the elevation animation ,或者

  3. 尝试通过 android:elevation 更改 TextView 的高度,使其高于 Button

关于android - RelativeLayout zorder Lollipop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682130/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com