所以,我有一个卡通人物拿着白板的照片。给你一个想法,图像就像这样。

现在,我想通过文本视图在这个白板的中央显示一些文字,这是字符在图像中所持有的。要显示的文本不太长,最多为4-5个字符.有可能做这样的事吗?如果是的话,这样做的方法是什么?
发布于 2016-02-20 08:09:54
是的,这可以使用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>如果这对你有用,请告诉我!)
发布于 2016-02-23 08:15:47
试试这个布局。这可能对你有帮助。
<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>为了正确定位图像和文本,使用页边距和相应的填充。
https://stackoverflow.com/questions/35520623
复制相似问题