gpt4 book ai didi

android-studio - Android studio 获取属性值

转载 作者:行者123 更新时间:2023-12-03 17:52:11 29 4
gpt4 key购买 nike

使用 Android Studio 中的特定主题找出代码中特定属性的值的最简单方法是什么?例如,当我在代码中看到属性 android:textColorPrimary 时,我想知道使用 Theme.AppCompat 解析的值为 @color/abc_primary_text_material_light。光

最佳答案

我刚刚找到了一种 super 简单的方法来找出值(value)。

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary" />

您想知道实际的颜色是什么。

您只需将光标放在 ?android:textColorPrimary 部分,然后单击查看 -> 快速文档(或按 F1 或其他方式)您分配给该操作的热键):

enter image description here

您可以转到设计选项卡并切换API级别等参数,然后返回文本选项卡,然后按F1将显示这些新参数的值。


下面是获得相同效果的更繁琐的方法:

对于主题的一些关键属性,例如 android:textColorPrimary,可以通过“工具”>“Android”>“主题编辑器”来查看和编辑它们。

appcompat.light

除此之外,如果您对布局中某些特定 View 使用的属性值感兴趣,您可以使用布局编辑器选择该 View ,然后在“属性” Pane 中选择查看所有属性,找到您感兴趣的属性,它应该显示该属性使用的默认属性,例如:

property

然后,您可以单击颜色来打开一个搜索资源的窗口,该窗口还向您展示 Android 如何将属性解析为具体值:

resources

关于android-studio - Android studio 获取属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40293434/

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