绘制文本背后的广场? [英] Draw square behind text?

查看:180
本文介绍了绘制文本背后的广场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如你所看到的广场是真棒,但我在底部(勉强可见)的文本是绘制正方形之后,并没有ontop广场的,因为我想。这是我的布局XML:

As you can see the square is awesome, but my text at the bottom (barely visible) is draw AFTER the square, and not ontop of the square as I would like. Here is my layout xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/abslayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/dragon"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image2"
        android:layout_width="match_parent"
        android:layout_height="100px"
        android:scaleType="fitXY"
        android:src="@drawable/banner3" />

    <ImageView
        android:id="@+id/image2"
        android:layout_width="172dp"
        android:layout_height="60dp"
        android:layout_gravity="center_horizontal"
        android:layout_weight="0.09"
        android:scaleType="fitXY"
        android:src="@drawable/playerInfoSquare" />

    <TextView
        android:id="@+id/playerName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginRight="10px"
        android:text="Player Name"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/playerHealth"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Heatlth : 0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/playerMana"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Mana : 0"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

最新最好的方式来绘制这些TextViews ontop我的美丽的广场?

Whats the best way to draw those TextViews ontop of my beautiful square?

推荐答案

试着用的FrameLayout。

Try with FrameLayout.

<FrameLayout >
    <ImageView
        android:id="@+id/image2"
        android:layout_width="172dp"
        android:layout_height="60dp"
        android:layout_gravity="center_horizontal"
        android:layout_weight="0.09"
        android:scaleType="fitXY"
        android:src="@drawable/playerInfoSquare" />

    <TextView
        android:id="@+id/playerHealth"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Heatlth : 0"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>

这篇关于绘制文本背后的广场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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