从布局 xml 文件中旋转 ImageView 源 [英] Rotate ImageView source from layout xml file

查看:60
本文介绍了从布局 xml 文件中旋转 ImageView 源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局中有这个 ImageView:

I have this ImageView in my layout:

<ImageView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/image_divider"
        android:paddingBottom="8dp"
        android:paddingTop="4dp"
        android:scaleType="fitXY"
        android:src="@android:drawable/divider_horizontal_textfield" />

这是一个水平分隔线.我想将它旋转 90 度,所以我有一个垂直分隔线.
有没有什么可能的方法可以从布局而不是 Activity 类中做到这一点?

It's a horizontal divider. I want to rotate it 90 degrees so I have a vertical divider.
Is there any possible way to do it right here from the layout and not the Activity class?

推荐答案

你可以使用Available since API Level 11

You can use Available Since API Level 11

android:rotation="90"

最终代码,

<ImageView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:rotation="90"
        android:contentDescription="@string/image_divider"
        android:paddingBottom="8dp"
        android:paddingTop="4dp"
        android:scaleType="fitXY"
        android:src="@android:drawable/divider_horizontal_textfield" />

这篇关于从布局 xml 文件中旋转 ImageView 源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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