我目前每個組件有兩個 xml 檔案來支持普通和大型設備。然而,對于這些檔案中的大多數,我在大桶中所做的只是復制正常大小的桶并將所有尺寸乘以大約 1.5。
例如:
活動主.xml:
<include layout="@layout/help_popup"/>activity_main.xml(大):
<include layout="@layout/help_popup"/>help_popup.xml:
<TextView android:text_size = 30dp />help_popup.xml(大):
<TextView android:text_size = 45dp />
應該變成這樣:
活動主.xml:
<include layout="@layout/help_popup"/>activity_main.xml(大):
<include layout="@layout/help_popup" android:multiply_dimensions = 1.5 />help_popup.xml:
<TextView android:text_size = 30dp />
help_popup.xml(大)
我現在正在為大規模使用額外的布局檔案。我用谷歌搜索并瀏覽了stackoverflow,我不確定是否存在我的問題的解決方案,但我想確定一下。
uj5u.com熱心網友回復:
您應該能夠通過使用普通和大尺寸的維度資源檔案來實作這一點,而不是使用普通和大尺寸的布局資源檔案。然后,您不需要大版本的 help_popup 和 activity_main,因為正常和大尺寸會相應地設定 help_popup TextView 的文本大小。像這樣:
尺寸.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="help_popup_text_size">30sp</dimen>
</resources>
dimens.xml(大):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="help_popup_text_size">45sp</dimen>
</resources>
help_popup.xml:
<TextView android:textSize="@dimen/help_popup_text_size"/>
活動主.xml:
<include layout="@layout/help_popup"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/528317.html
標籤:安卓安卓布局安卓约束布局
