【问题标题】:Xamarin Android Style Xml AttributesXamarin Android Style Xml 属性
【发布时间】:2019-10-05 10:35:02
【问题描述】:

在我们创建的布局 xml 文件中。我们有时使用'@' & '?'属性是什么意思

例如,我创建了 toolbar.xml 。我可以看到 ?android:attr/actionBarSize 这是什么意思

&@android:style/**ThemeOverlay.Material.Dark.ActionBar" 是什么意思

<?xml version="1.0" encoding="utf-8"?>
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="**?android:attr/actionBarSize**"
    android:background="**?android:attr/colorPrimary**"
    android:theme="**@android:style/**ThemeOverlay.Material.Dark.ActionBar"/>

【问题讨论】:

  • 你现在了解属性了吗?
  • 谢谢我现在明白了。

标签: android xamarin


【解决方案1】:

如果你阅读了关于ResourcesFromCode的文档,你会发现

如果您使用 @...,则表示a syntax to reference a resource in an XML resource

@[<package_name>:]<resource_type>/<resource_name>

如果你使用 ?...,那意味着你是referencing a style attribute and the resource type portion is optional

?[<package_name>:][<resource_type>/]<resource_name>

您可以在document获取更多示例和详细信息。

这是一个可能有帮助的链接:question-mark-in-xml-attributes-for-android

【讨论】:

    猜你喜欢
    • 2017-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 2017-02-27
    相关资源
    最近更新 更多