將旋轉的文本放在圖像視圖上 (Put rotated text on an imageview)


問題描述

將旋轉的文本放在圖像視圖上 (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 martinyyyyCristian)

參考文件

  1. Put rotated text on an imageview (CC BY‑SA 3.0/4.0)

#imageview #Android #textview #xml






相關問題

Android imageview 未在 TableRow 中顯示 (Android imageview not displaying in TableRow)

Android中的手勢 (Gestures in Android)

GridView kéo dài ImageView không đồng nhất (GridView Stretching ImageView Non-Uniformly)

ios在表格視圖單元格中視覺調整圖像大小 (ios visually resize image in a table view cell)

IndoorAtlas SDK 2.0:使用 Picasso 和自定義 ImageView (IndoorAtlas SDK 2.0: Using Picasso with custom ImageView)

當圖像的寬度小於顯示器的寬度時,如何在視圖尋呼機內對齊圖像視圖的中心? (How to align center an image view inside a view pager when the image's width is less than the display's?)

正確旋轉 ImageView 和 FrameLayout (Rotate ImageView and FrameLayout correctly)

setOnClickListener 沒有在圖像視圖上被調用 (setOnClickListener is not getting called on image view)

Android:擴展 onTouchEvent 以進行拖動的 ImageView (Android: ImageView that extends onTouchEvent for Drag)

將旋轉的文本放在圖像視圖上 (Put rotated text on an imageview)

如何在底部設置圖像視圖 (how to set imageview in bottom)

我如何使用數組來顯示匹配的 Imageview? (How Could I use array to show match Imageview?)







留言討論