Make a text view overlay another text view

假装没事ソ 提交于 2019-12-12 06:39:25

问题


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>

回答1:


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.

Change this line:

android:layout_below="@id/org_name"

To this:

android:layout_alignBottom="@id/org_name"

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




回答2:


The reason they aren't overlapping is the android:layout_below="@id/org_name" in the second TextView. If you remove that, I think it should work as you want it to. If not, you might want to try a FrameLayout instead of a RelativeLayout.



来源:https://stackoverflow.com/questions/20671887/make-a-text-view-overlay-another-text-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!