所以,我得到了一个卡通人物拿着白板的形象。给你一个想法,图像是这样的。如何在ImageView上的特定位置显示文本?
现在,我想表明通过TextView的这个白板的中央一些文字,字符持有的形象。要显示的文本不会太长,最长4-5个字符。是否有可能做这样的事情?如果是这样,那么执行此操作的方法是什么?
所以,我得到了一个卡通人物拿着白板的形象。给你一个想法,图像是这样的。如何在ImageView上的特定位置显示文本?
现在,我想表明通过TextView的这个白板的中央一些文字,字符持有的形象。要显示的文本不会太长,最长4-5个字符。是否有可能做这样的事情?如果是这样,那么执行此操作的方法是什么?
是的,这可以使用FrameLayout完成。
步骤1:所有的首先借此ImageView的一个相对布局
步骤2内:然后采取相对布局内的的FrameLayout。
3步:这里面的FrameLayout你可以把你的TextView,然后你可以通过为重力,填充等
下面是代码样本您的位置您的TextView!
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
/// this is your imageview
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Enter Your Text Here"/>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
让我知道这对你的作品!:)
试试这个布局。这可能会帮助你。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
// this is your imageview
<ImageView
android:layout_gravity="center" /// you can change this property according to your requirement to 'right', 'left' etc
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_gravity="center" /// you can change this property according to your requirement to 'right', 'left' etc
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Enter Your Text Here"/>
</FrameLayout>
为了正确定位图像和文字,请相应地使用边距和填充。
使用画布...获取米奇板的坐标并在其上绘制文本。 –
如何找到电路板的坐标? – Harry
如果您使用的是ImageView,如果您想知道它是如何缩放的(因此白板的顶部/左侧角落在哪里),可以使用ImageView#getImageMatrix( )'方法 – pskink