[英]Managing activity background image
I want to set a 320x240 image as background of the activity in two ways. 我想通过两种方式将320x240的图像设置为活动的背景。
First one is to set this image in the center on the activity, not enlarging it - keeping the original size of the image. 第一个是将此图像设置在活动中心,而不是放大图像-保持图像的原始大小。 Second one, also in the center, but enlarning to 500x400.
第二个也位于中心,但放大到500x400。
Using simply android:background="@drawable/background
enlarges the image to the activity size. What do I have to do to achieve these effects? 只需使用
android:background="@drawable/background
将图像放大到活动大小。要实现这些效果我该怎么办?
Use 采用
android:scaleType="centerInside"
if you want to keep the image inside the frame without stretching. 如果您想将图像保持在框架内而不会拉伸。 Then you can set the image in your code
然后您可以在代码中设置图片
((ImageView)findViewById(R.id.your_imageview)).setImageResource(R.drawable.background);
In the second case, you may look into how to set image size 在第二种情况下,您可能会研究如何设置图像尺寸
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.