2013-05-18 78 views
2

我不能把標籤放在我想要的地方。我會展示一張照片。TextView below ImageView

enter image description here

我有以下代碼:

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textViewNombreVideo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/imageViewLogo" 
     android:layout_alignParentBottom="true" 
     android:layout_alignRight="@+id/imageViewLogo" 
     android:lines="2" 
     android:scrollHorizontally="false" 
     android:singleLine="false" 
     android:text="Medium Text" 
     android:textAppearance="?android:attr/textAppearance" 
     android:textColor="@android:color/white" 
     android:textColorLink="@android:color/white" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/imageViewLogo" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/textViewNombreVideo" 
     android:layout_centerHorizontal="true" 
     android:layout_margin="4dp" 
     android:adjustViewBounds="true" /> 

</RelativeLayout> 

畫面適合的ImageView的喚起注意,這是確定的,我要放置的TextView與圖片相同的左側。

有沒有可能這樣做?

回答

0

我認爲你有重力選項添加到您的TextView:

安卓重力= 「中心」

0

試試這個

無需採取RelativeLayout調整,你可以簡單地實現TextView再見簡單設置android:drawableTop屬性TextView

實施例:android:drawableTop="@drawble/yourimage"

 <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:drawableTop="@drawble/yourimage" 
     android:text="Hello" 
     /> 
2

嘗試此代碼。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textViewNombreVideo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_alignLeft="@+id/imageViewLogo" 
     android:layout_alignParentBottom="true" 
     android:layout_alignRight="@+id/imageViewLogo" 
     android:lines="2" 
     android:scrollHorizontally="false" 
     android:text="Medium Text" 
     android:textAppearance="?android:attr/textAppearance" 
     android:textColor="@android:color/black" 
     android:textColorLink="@android:color/white" 
     android:textStyle="bold" 
     android:layout_marginBottom="10dp" /> 

    <ImageView 
     android:id="@+id/imageViewLogo" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/textViewNombreVideo" 
     android:layout_centerHorizontal="true" 
     android:layout_margin="4dp" 
     android:src="@drawable/ic_launcher" 
     android:adjustViewBounds="true" 
    /> 

</RelativeLayout> 

從這個代碼的UI設計下面。根據您的要求。

enter image description here

0

使用按鈕代替的ImageView和TextView的作爲..

<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button Text" 
     android:drawableTop="@drawable/youriconname" 

     /> 

嘗試這可能會幫助你..