旋转ImageView而不丢失高度
问题描述:
我在Android Studio上遇到ImageView
问题。旋转ImageView而不丢失高度
基本上,当我旋转视图(90°)时,尺寸被交换(高度现在是宽度和宽度现在为高度),导致ImageView
超出界限。 现在已经有两天了,我真的需要一个答案。
N.B - 我用setImageResource
在ImageView
编程设置资源
谢谢!
答
您可以尝试this库链接如下
在项目中包含的的build.gradle
compile 'rongi.rotate-layout:rotate-layout:3.0.0'
和你需要用“RotateLayout”
来包装你的视图旋转目的这个库的依赖<com.github.rongi.rotate_layout.layout.RotateLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:angle="90"> <!-- Specify rotate angle here -->
<YourLayoutHere
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</YourLayoutHere>
</com.github.rongi.rotate_layout.layout.RotateLayout>
如果你想programmtically旋转它,然后
int newAngle = rotateLayout.getAngle() + 90;
rotateLayout.setAngle(newAngle);
答
根据您提供的信息(本例中应提供布局示例),我认为您需要的是在图像视图中更改scaleType
。
看到这篇文章的不同选项的一个很好的视觉指南:Android ImageView ScaleType: A Visual Guide。
谢谢,我会试试看! 它的工作,最后!谢啦! –
尽管这个链接可能回答这个问题,但最好在这里包含答案的基本部分,并提供参考链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/17185902) – Drunix
@Drunix感谢您的评论。答案已更新。 – patilmandar2007