Rotate ImageView source from layout xml file

mehrmoudi picture mehrmoudi · Jun 28, 2012 · Viewed 78.7k times · Source

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" />

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?

Answer

Rinkal Bhanderi picture Rinkal Bhanderi · Jun 28, 2012

You can use Available Since API Level 11

android:rotation="90"

Final Code to Put,

<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" />