[英]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>
知道我所缺少的,或者如何改變以獲得我想要的嗎?
請嘗試下面的鏈接,希望對您有所幫助:-
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.