首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >getLayoutParams()..height/width

getLayoutParams()..height/width
EN

Stack Overflow用户
提问于 2011-12-31 13:32:28
回答 1查看 1.5K关注 0票数 0

我尝试使用getLayoutParams().height/width设置图像的大小,但问题是,我所有的数字都存储在values文件夹中。我知道我可以只设置getLayoutParams().height= 500;但是我想使用values.xml中的数字。还有没有别的办法呢?我尝试了getLayoutParams().height=R.integer.ImageWidth,但不起作用。

代码语言:javascript
复制
<integer name="ImageWidth">501</integer>
<integer name="ImageHeight">200</integer>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-31 14:12:11

好吧,我自己还没试过,但这可能行得通。

代码语言:javascript
复制
Resources res = getResources();
int imageWidth = res.getInteger(R.values.ImageWidth);
int imageHeigth = res.getInteger(R.values.ImageHeigth);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8686514

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档