繁体   English   中英

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

[英]Place view on top and between two views

试图找出解决这个小问题的方法。

下面左侧是我尝试为应用程序实现的视图示例。 右边是我最终得到的视图。 容器

在我的xml模型中,我决定使用RelativeLayout但是我无法让TextView居于顶视图和底视图之间。

供参考,这里是我的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>

知道我所缺少的,或者如何改变以获得我想要的吗?

请尝试下面的链接,希望对您有所帮助:-

布局中图像视图上方的TextView

Android Listview项目使用数组适配器在图像上显示文本

如何在图像视图下放置文本

 <?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