如何从自定义属性中引用android属性layout_width?

isa*_*ent 8 layout android attributes custom-attributes

我想将我的应用程序在xlarge设备上的使用和其他设备上的使用分开,将layout_width参数限制为xdge的720dp.为此我创建了values/attrs.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <attr name="layoutWidth" format="reference|dimension" />
</resources>
Run Code Online (Sandbox Code Playgroud)

使用自定义参数layoutWidth将其设置为

android:layout_width="?layoutWidth"
Run Code Online (Sandbox Code Playgroud)

Furtner,我需要在values-xlargevalues目录中为xlarge和普通设备指定两个themes.xml文件 :

值-XLARGE /的themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="android:Theme">
        <item name="layoutWidth">720dp</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

值/的themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="android:Theme">
        <item name="layoutWidth">What should I write here!?</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

那么,如何在这个地方对Android"fill_parent"参数进行参考呢?好像是@android:layout_width/fill_parent,但是我编译错误:

 No resource found that matches the given name (at 'layoutWidth' with value '@android:layout_width/fill_parent').
Run Code Online (Sandbox Code Playgroud)

isa*_*ent 10

我通过将values/attrs.xml更改为:找到了解决方案:

<?xml version="1.0" encoding="UTF-8"?>
<resources>    
    <attr name="layoutWidth" format="dimension">
        <enum name="fill_parent" value="-1" />
        <enum name="match_parent" value="-1" />
        <enum name="wrap_content" value="-2" />
    </attr>
</resources>
Run Code Online (Sandbox Code Playgroud)

现在,我可以写入values/themes.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="android:Theme"> 
        <item name="layoutWidth">match_parent</item>
    </style>
<resources>
Run Code Online (Sandbox Code Playgroud)

但问题仍然存在:是否有可能从这个地方引用Android layout_width参数?