避免Android布局中的数字?

避免Android布局中的数字?,第1张

概述是否可以设计Android布局(LinearLayout或RelativeLayout)而无需指定任何dp,px或任何其他单位?也许使用百分比?layout_weight是一个选项.但是利润率和填充量仍然如此?我们可以完全避免布局中的魔术数字吗?解决方法:有PercentSupportLibrary及其PercentFrameLayout和PercentRelativeLa

是否可以设计Android布局(linearLayout或relativeLayout)而无需指定任何dp,px或任何其他单位?也许使用百分比? layout_weight是一个选项.但是利润率和填充量仍然如此?我们可以完全避免布局中的魔术数字吗?

解决方法:

有Percent Support Library及其PercentFrameLayoutPercentRelativeLayout,你可以用百分比而不是绝对值指定任何布局尺寸(即尺寸,位置和边距):

<androID.support.percent.PercentrelativeLayout         xmlns:androID="http://schemas.androID.com/apk/res/androID"         xmlns:app="http://schemas.androID.com/apk/res-auto"         androID:layout_wIDth="match_parent"         androID:layout_height="match_parent">     <ImageVIEw         app:layout_wIDthPercent="50%"         app:layout_heightPercent="50%"         app:layout_margintopPercent="25%"         app:layout_marginleftPercent="25%"/></androID.support.percent.PercentrelativeLayout>
总结

以上是内存溢出为你收集整理的避免Android布局中的数字?全部内容,希望文章能够帮你解决避免Android布局中的数字?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1115024.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存