gpt4 book ai didi

android - PercentRelativeLayout margin_percent 在某些情况下不起作用

转载 作者:行者123 更新时间:2023-11-29 02:41:16 25 4
gpt4 key购买 nike

Nougat 中的以下 xml 忽略了 marginRightPercent。

  <?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_alignParentRight="true"
app:layout_heightPercent="3.45%"
app:layout_marginRightPercent="5.07%"
app:layout_marginTopPercent="2.85%"
app:layout_widthPercent="6.13%"
android:scaleType="fitCenter"
android:src="@drawable/action_bar_notification"/>
.
.
.
.
.
</android.support.percent.PercentRelativeLayout>

我的应用程序中还有其他地方没有忽略它,但那些其他地方没有 layout_widthPercent。这在 6.0 中工作正常,但我认为这是 7.0 中的错误。

最佳答案

添加 android:layout_marginRight="1dp" - 它可以是任何值。您只需添加它,然后像 app:layout_marginRightPercent 这样的值就会起作用。我不知道为什么 - 来自 documentation我推断它无论如何都应该起作用。

在新项目中,我们使用 ConstraintLayout,因为 PercentRelativeLayout 自 API 26 以来已被弃用

关于android - PercentRelativeLayout margin_percent 在某些情况下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43891305/

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