在Android的画布上添加EditText



我是安卓系统的新手。当用户点击画布时,我需要在画布上添加文本。编辑文本应该弹出,当用户完成编辑时,编辑文本中的文本将与imageview位图组合。我需要帮助在imageview上获得编辑文本,用户可以在其中输入文本。我还需要能够在imageview 中移动编辑文本

将一个视图放在另一个视图上的方法是将它们放在FrameLayout

如本例所示:

<FrameLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/mainlayout"
 android:layout_height="math_parent"
 android:layout_width="math_parent" />
       <ImageView
         android:id="@+id/textView2" 
         android:layout_height="match_parent" 
         android:layout_width="match_parent" 
         android:src="@drawable/yourDrawable"/>
       <EditText
               android:id="@+id/EditText1" 
               android:layout_height="50dp" 
               android:layout_width="200dp" 
               android:layout_marginTop="100dp"
               android:layout_marginLeft="70dp"
               android:text="" 
               android:textsize="15dp" />
</Framelayout>

正如在这个博客文章中看到的

如您所见,我使用页边空白将EditText放置在图像上。

       android:layout_marginTop="100dp"
       android:layout_marginLeft="70dp"

最新更新