Android 文本视图上的图像视图

Android 文本视图上的图像视图,android,listview,textview,imageview,android-relativelayout,Android,Listview,Textview,Imageview,Android Relativelayout,有没有办法,如何将ImageView放在TextView上?我尝试了很多方法,但是文本视图总是带有“优先级”并显示在顶部(在图像上)。你知道怎么做吗? (右侧绿色文本-“DNES”是图像视图,“sobota…”是文本视图) XML布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au

有没有办法,如何将ImageView放在TextView上?我尝试了很多方法,但是文本视图总是带有“优先级”并显示在顶部(在图像上)。你知道怎么做吗? (右侧绿色文本-“DNES”是图像视图,“sobota…”是文本视图)

XML布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="220dp"
    android:minHeight="220dp"
    android:padding="4dp"
    android:background="@drawable/event_card" >


   <ImageView
        android:id="@+id/event_poster"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:src="@drawable/stub_img_new"
        android:scaleType="centerCrop" />

    <RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="90dp"
    android:minHeight="90dp"
    android:background="#D9F0F0F0" >


     <cus.haw.sat.ImageViewRounded
        android:id="@+id/event_club_logo"
        android:layout_width="78dp"
        android:layout_height="78dp"
        android:scaleType="fitXY"
        android:layout_marginLeft="5dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true" />


     <cus.haw.sat.AutofitTextView
        android:id="@+id/event_title"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/event_club_logo"
        android:textSize="17sp"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="7dp"
        android:layout_alignParentTop="true"
        android:layout_marginTop="5dp"
        android:maxLines="2"
        android:textStyle="bold" />

      <cus.haw.sat.AutofitTextView
        android:id="@+id/event_club_title"
        android:layout_width="105dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/event_club_logo"
        android:textSize="15sp"
        android:layout_marginLeft="7dp"
        android:gravity="bottom"
        android:layout_marginRight="7dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:maxLines="2" />

      <ImageView
        android:id="@+id/event_today"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="20dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:src="@drawable/ic_today"
         />

      <TextView
        android:id="@+id/event_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textSize="14sp"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="7dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:maxLines="3" />

    </RelativeLayout>


     <RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="29dp"
    android:minHeight="39dp"
    android:background="#D9F0F0F0"
    android:layout_alignParentBottom="true"
    android:paddingLeft="4dp"
    android:paddingRight="4dp" > 

         <cus.haw.sat.AutofitTextView
        android:id="@+id/event_bonus"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        android:gravity="center"
        android:layout_centerInParent="true"
        android:maxLines="2" />

    </RelativeLayout>





</RelativeLayout>

一个
RelativeLayout
FrameLayout
的子级顺序控制Z轴。后面的子对象(例如,XML文件中的后面)在Z轴上的位置较高。因此,如果希望
图像视图
浮动在
文本视图
之上,请确保
图像视图
的定义晚于
文本视图
作为同一
相对视图
的子级

相对视图
框架布局
的子级顺序控制Z轴。后面的子对象(例如,XML文件中的后面)在Z轴上的位置较高。因此,如果您希望
图像视图
浮动在
文本视图
之上,请确保
图像视图
的定义晚于
文本视图
,作为相同
相对性视图

的子级更改子级顺序:“在下面的平均值之后”

这应该行得通;)

更改子项顺序:“后面的意思如下”


这应该行得通;)

是的,使用RelativeLayout或FrameLayout是的,使用RelativeLayout或FrameLayout好的,非常感谢!但我还有另一个问题:如果切换视图(id:eventToday&eventDaty),ListView会立即消失。“你不知道哪里会出问题吗?”马森:我不知道。在模拟器中使用层次结构视图来确定发生了什么。感谢您的努力,它现在可以工作了。我刚刚更改了textview的id。Idk为什么会发生这种事。好吧,非常感谢你!但我还有另一个问题:如果切换视图(id:eventToday&eventDaty),ListView会立即消失。“你不知道哪里会出问题吗?”马森:我不知道。在模拟器中使用层次结构视图来确定发生了什么。感谢您的努力,它现在可以工作了。我刚刚更改了textview的id。Idk为什么会这样。