我有一個android項目,我使用相機並將圖片保存在imageView中。 所以,我想在這個imageView上粘貼一些文字。這是可能的 ??如何在Android的imageview上「粘貼」一些文字?
0
A
回答
0
遵循以下步驟:
步驟1:首先佈局更改爲RelativeLayout
步驟2:單擊並拖動您的工作空間內ImageView的按鈕,選擇您已存儲在您繪製文件夾中的圖像。
第3步:選擇TextView
並將其拖入圖像的中心。 (Rightclick-EditText-改變成你想要的文字)。
您還可以使用TEXTSTYLE或TEXTSIZE,使文本大和格式化。
下面是簡單的示例代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/sm" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="148dp"
android:textStyle="bold"
android:text="Here is my text " />
</RelativeLayout>
結果:
0
創建一個RelativeLayout
或FrameLayout
,其中包含您的ImageView
和TextView
。 TextView
將出現在ImageView
之上。
0
使用TextView
並將圖像背景設置爲文本視圖。
或
如果你想使用圖像視圖然後創建TextView
並放置兩個TextView
& ImageView
在RelativeLayout
。
1
寫這樣的事情你RelativeLayout
裏面:
<ImageView
android:id="@+id/myImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/imageSouce" />
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textview1"
android:layout_alignTop="@+id/textview1"
android:layout_alignRight="@+id/textview1"
android:layout_alignBottom="@+id/textview1"
android:layout_margin="1dp"
android:gravity="center"
android:text="Hello"
android:textColor="#000000" />
或者, 想這樣做編程,然後按照..
相關問題
- 1. Unsticky粘粘貼的一些
- 2. 我貼在UILabel粘貼文本的一些錯誤
- 3. 如何在Android上移動或複製/粘貼文件
- 4. 在粘貼事件上獲取粘貼文檔的內容
- 5. 如何令牌粘貼一個數字?
- 6. 粘貼字體粘貼到剪貼板
- 7. 如何從Android上的剪貼板粘貼時刪除文本格式
- 8. Vim的替換一些詞粘貼
- 9. 如何從剪貼板粘貼文本?
- 10. Android攔截在editText上粘貼\ copy \ cut
- 11. VIM:如何在一些起始行中粘貼
- 12. NSTextView粘貼:當粘貼「foo」時,如何粘貼「bar」?
- 13. 粘貼在一頁上的按鈕
- 14. 如何當我使用getTransferData(選擇DataFlavor.stringFlavor)一些文本從剪貼板粘貼一樣從剪貼板中的數據粘貼到文本區域
- 15. 粘貼在QTableView的字段
- 16. Javascript?文檔粘貼事件 - 獲取粘貼的文本在FireFox
- 17. 如何在ng-paste中粘貼文本?
- 18. 粘貼輸出到bash的一個CSV文件,粘貼命令
- 19. 將一些元素粘貼到左側,並將其他元素粘貼在同一行上
- 20. 如何在Windows VNC上修復損壞的粘貼剪貼板
- 21. 如何在java中複製粘貼和剪切粘貼文件或文件夾?
- 22. 如何在粘貼後跳到粘貼內容的結尾?
- 23. 當我在這個輸入中粘貼一些文本時,inputtring的值在粘貼時爲零
- 24. 在Android的另一個圖像上粘貼圖像
- 25. Android粘貼按鈕
- 26. 如何操縱字符串以便在Android中粘貼
- 27. 如何在android的imageview上保留文字?
- 28. 如何將一個字節數組粘貼到文件c#中?
- 29. 粘貼當前在剪貼板上的文本在ASP.NET中
- 30. 如何限制在文本框中粘貼的字符數?
我試圖做到這一點,但我不能設置的TextView的位置在imageview的 – user2550055
發佈您的代碼和或XML。 – techiServices