如何在 imageView 上设置文本? [英] how to set a text over an imageView?

查看:56
本文介绍了如何在 imageView 上设置文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在屏幕顶部放置了一个应用程序栏,如下图所示:

I am placing an application bar on the top of the screen and it looks as the following figure:

现在我想在图像上设置一个文本,使图像如下所示:

Now i want to set a text over the image, so that the image looks as follows:

如何在图片上设置文字?提前致谢

How to set a text over an image? Thanks in advance

推荐答案

请试试下面的代码.

<?xml version="1.0" encoding="utf-8"?>

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" 
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="@drawable/your background image">


            <LinearLayout 
                android:layout_height="fill_parent"
                android:layout_width="fill_parent" 
                android:layout_weight="1"
                android:gravity="center" 
                android:orientation="vertical">

                <TextView 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" 
                    android:textColor="@color/white"
                    android:textSize="18sp" 
                    android:textStyle="bold"
                    android:singleLine="true" 
                    android:text="Subject"/>

            </LinearLayout>

</LinearLayout>

这篇关于如何在 imageView 上设置文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆