gpt4 book ai didi

android - 如何在 PercentRelativeLayout 中使百分比动态化?

转载 作者:行者123 更新时间:2023-11-30 00:55:22 26 4
gpt4 key购买 nike

我正在使用设计支持库中的 PercentRelativeLayout,我想为 7 英寸和 10 英寸平板电脑设置不同的百分比。

例如,如果我有如下所示的 ImageView

<ImageView
android:id="@+id/contactDoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_widthPercent="70%"
app:layout_heightPercent="70%"
android:layout_centerHorizontal="true"
android:clickable="true"
android:src="@drawable/dashboard_contactdoctor" />

现在,如果我想为 7 英寸平板电脑设置 70%,为 10 英寸平板电脑设置 60%,而不创建不同的布局文件夹,如 sw720dp。我可以做吗?感谢您的帮助。

最佳答案

这些百分比是 fraction 资源。您应该能够设置 res/values/fractions.xmlres/values-sw720dp/fractions.xml,其中 define the values for the fractions .然后,在布局中使用 @fraction/whatever_you_called_it

关于android - 如何在 PercentRelativeLayout 中使百分比动态化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40261570/

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