gpt4 book ai didi

android - 避免在 android 中重复 fill_parent & wrap_content & match_parent

转载 作者:太空狗 更新时间:2023-10-29 14:20:53 24 4
gpt4 key购买 nike

我有很多

android:layout_width="fill_parent"

&

android:layout_height="wrap_content"

我的应用程序项目中的属性。所以我想以如下样式添加它们。

<style name="layout_wf_hw">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="layout_ww_hw">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>

样式.xml

<style name="inputbox" parent="layout_wf_hw">
<item name="android:background">@drawable/editviewstyle</item>
</style>

现在我的代码 View 是

<EditText style="@style/inputbox"/>

我的问题是我们可以这样申请吗?这是我遵循的正确方法吗?

谢谢

最佳答案

我没有看到您的代码中不允许的任何内容。

其实我觉得是尊重DRY原则,这是一件好事。

唯一令人恼火的是,对于其他开发人员来说,第一次理解和阅读它可能有点困难。

所以我的回答是:为什么不。

关于android - 避免在 android 中重复 fill_parent & wrap_content & match_parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16978949/

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