問題描述
將旋轉的文本放在圖像視圖上 (Put rotated text on an imageview)
嗨,我需要在圖像視圖上放一些文字。
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/bg"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TEST"
/>
但這並不只顯示圖片的文本。而且我還必須旋轉這個文本。使用 TextView 是否也能做到這一點?
參考解法
方法 1:
There's nothing in the default TextView implementation that allows you to rotate the text. You will have to create your a custom view. Take a look at this question: Vertical (rotated) label in Android.
In that case, I think it'd be much easier to modify the bitmap representation of the ImageView
and add the rotated text (which you can do using the Canvas
methods like rotate, restore, etc... you can easily find information about that on Google).
(by martinyyyy、Cristian)