使一个文本视图覆盖另一个文本视图 [英] Make a text view overlay another text view

查看:141
本文介绍了使一个文本视图覆盖另一个文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在上面的文本视图上放置一个文本视图,但我尝试将文本对齐,但是没有成功,我可以通过添加大量的填充来完成此操作,但是我不想使用填充,因为我在屏幕尺寸中遇到android各种其他问题.我将发布我要执行的操作的图像,然后发布我拥有的xml代码.希望在这里寻求帮助,谢谢.Image(我正在尝试使带有文本android/Design的黑条覆盖上述表示繁忙开发的区域,到目前为止,黑文本视图只是将上述文本视图向上推,如果我希望它只是覆盖但保留在相同位置) http://imgur.com/ebgNTNk

I am try to make a text view over lay the above text view i have try'ed the text align but with no success i can accomplish this with adding a large amount of padding but i do not want to use padding because i run in to other issues in android variety in screen sizes. I will post an image of what i am trying to do and also post then xml code i have. Looking foward to some help here thanks.Image(I am trying to make that black bar with the text android /Design overlay the above area that says busybusy Development as of right now the black text view is just pushing the above text view up were i would like it to just overlay but stay in it same position) http://imgur.com/ebgNTNk

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">



    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/org_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:gravity="center_horizontal"
            android:paddingTop="42dp"
            android:paddingBottom="42dp"
            android:background="@drawable/dashboard_business_image"
            android:textColor="@color/busy_black"
            android:textStyle="bold"
            android:textAppearance="?android:attr/textAppearanceMedium">
        </TextView>

        <TextView
            android:id="@+id/project_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_below="@id/org_name"
            android:layout_marginRight="4dp"
            android:gravity="center_horizontal"
            android:layout_gravity="bottom"
            android:paddingTop="2dp"
            android:paddingBottom="2dp"
            android:background="@color/busy_translucent_black"
            android:textColor="@color/busy_white"
            android:textStyle="normal"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:visibility="gone">
        </TextView>
    </RelativeLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">

        <include layout="@layout/dashboard_clock_in_button" />
        <include layout="@layout/dashboard_clock_out_button" />
        <include layout="@layout/dashboard_paused_button" />

        <ListView
            android:id="@+id/action_list"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:divider="@color/busy_divider_color"
            android:dividerHeight="0dp">
        </ListView>

    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_weight="0"
        android:gravity="center_horizontal"
        android:paddingTop="32dp"
        android:paddingBottom="32dp"
        android:background="@color/busy_white"
        android:textColor="@color/busy_black"
        android:textStyle="bold"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

推荐答案

在阅读本文时,您似乎希望project_name视图覆盖org_name视图.您可以通过对齐视图底部来做到这一点.

Reading this, it appears you want the project_name view to overlay the org_name view. You can do this by aligning the bottom of the views.

更改此行:

android:layout_below="@id/org_name"

对此:

android:layout_alignBottom="@id/org_name"

这将使两个视图的底部对齐,从而有效地将project_name放置在org_name视图的顶部.

That will align the bottom of the two views, effectively placing project_name on top of the org_name view.

这篇关于使一个文本视图覆盖另一个文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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