Android的如何设置一个百分比填充/保证金,以便EditText上有10%的保证金对任何一方? [英] Android how do I set a percentage padding/margin so EditText has 10% margin on either side?

查看:113
本文介绍了Android的如何设置一个百分比填充/保证金,以便EditText上有10%的保证金对任何一方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否支持Android%或者是有办法接近。我有两个非常不同的屏幕尺寸,我可是个明智我想在活动编辑框具有相同的保证金为屏幕大小屏幕尺寸的比例。如何才能做到这一点。

Does android support % or is there a way to approximate. I have two very different screen sizes and I but percentage-wise I want the EditBox in the activity to have same margin for both screen size as a proportion of screen size. How can this be done.

推荐答案

它并不真正支持百分比设定值(除了某些XML动画文件似乎)如果你是死心塌地的使用比例最好这样我能想到的是从Java调用的getWidth和getHeight再乘以那些你十进制和设置结果与setMargin(),或setPadding()。

It doesn't really support setting values by percent(except for some of the xml Animation files seem to) If you are dead set on using a percentage the best way I can think of is from java call getWidth and getHeight then multiply those by your decimal and set the result with setMargin(), or setPadding().

这篇关于Android的如何设置一个百分比填充/保证金,以便EditText上有10%的保证金对任何一方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆