2013-08-27 39 views
0

我有一些帶有一些元素的ScrollView。 我的問題是,我不能在動態高度上設置textview上面的ImageView。帶有動態高度的ImageView上方的TextView

我有3個不同高度的ImageView,它們可以被看到或消失。 他們上面我需要把與背景色文字,這段文字必須在ImageView的 的底部ImageView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ImageView 
     android:id="@+id/pic" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
</ImageView> 
<TextView 
     android:id="@+id/third_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="16dp" 
     android:padding="8dp" 
     android:layout_alignParentBottom="true" 
     android:layout_above="@id/third_picture" 
     android:gravity="center_horizontal" 
     android:background="@android:color/white" 
     android:text="example text"> 
</TextView> 

我嘗試了很多,但我的觀點是永遠打破。 請幫助,我需要一些proffesional建議。

+1

你可以嘗試用你選擇的任何圖像這 - 組佈局的背景....並把TextView的正常...無imageview的需要 – WISHY

回答

1

可以在TextView中做到這一點:

android:layout_alignBaseline="@id/pic" 

這將調整的TextView的基線與ImageView的

0

您可以將圖片作爲佈局的背景(如線性佈局)basline而比使用一個ImageView,然後把它放在它裏面的文本,並把它放在你想要的地方。

<LinearLayout 
     android:background="your picture" > 

      <!-- align it to the bottom --> 
      <TextView 

       /> 


    </LinearLayout> 
+0

可以將其擴展到cropCenter?如果沒有 - 這不是我所需要的 – AndrewS