简体   繁体   English

旋转中心图像

[英]Center image view on rotate

I have an image view with an image and it looks find when the phone is portrait. 我有一个带有图像的图像视图,当手机为人像时,它看起来可以找到。 When I turn it landscape, it rotates, however, the image isn't centered anymore. 当我将其旋转时,它会旋转,但是图像不再居中。 How do I go about doing that? 我该怎么做?

Create a layout-land directory in your res folder. res文件夹中创建一个layout-land目录。 And copy your layout files with landscape orientation. 并以横向方向复制布局文件。 That should do it. 那应该做。

Rather than making a new folder and xml file and all that, I simply did 与其制作一个新的文件夹和xml文件,不如说我只是做了

android:layout_width="match_parent"

on my image view and when I rotate the device, the image stays centered. 在图像视图中,当我旋转设备时,图像保持居中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM