简体   繁体   English

将视图放在顶部和两个视图之间

[英]Place view on top and between two views

Trying to figure out to overcome this little problem. 试图找出解决这个小问题的方法。

Below, on the left side, is a sample of the view that I'm trying to implement for an app. 下面左侧是我尝试为应用程序实现的视图示例。 On the right side is the view that I'm ending up with. 右边是我最终得到的视图。 容器

In my xml mock up I've decided to use a RelativeLayout but I can't get the TextView to be centered between the top and bottom views. 在我的xml模型中,我决定使用RelativeLayout但是我无法让TextView居于顶视图和底视图之间。

For reference here's a represenation of my xml code: 供参考,这里是我的xml代码的代表:

 <RelativeLayout 
    android:layout_width:"match_parent"
    android:layout_height:"wrap_content">
    <ImageView
        android:id="@+id/BlackImage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:layout_alightParentTop="true"
        android:layout_centerHorizontal="true"/>
    <ImageView
        android:id="@+id/RedImage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:layout_below="@+id/BlackImage"
        android:layout_centerHorizontal="true"/>
    <TextView
        android:id="@+id/TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/BlackImage"
        android:layout_centerHorizontal="true"/>
 </RelativeLayout>

Any idea what I'm missing, or how to change to get what I want? 知道我所缺少的,或者如何改变以获得我想要的吗?

try below link hope it will help you :- 请尝试下面的链接,希望对您有所帮助:-

TextView above Image view in a layout 布局中图像视图上方的TextView

Android listview item display text over image using array adapter Android Listview项目使用数组适配器在图像上显示文本

how to put text under image view 如何在图像视图下放置文本

 <?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" android:background="@drawable/tmp" >


        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/uph" 
             android:layout_marginTop="-10dp"/>

        <RelativeLayout  android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:layout_gravity="top|center">

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/propfile" 
            />

           <TextView  android:layout_width="wrap_content"
               android:layout_height="wrap_content" 
               android:text="text" 
               android:layout_centerInParent="true"
           /> 
      </RelativeLayout>   
    </LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM