2013-10-08 42 views
0

我正在創建一種圖像庫(含視圖鰭狀肢),其中viewflipper的每個視圖都有一個imageview和兩個下方的textview。我想要的是根據圖像瀏覽寬度調整這些textviews的寬度。這些imageview和文本動態添加到viewflipper,因此無法在xml中調整寬度。此外,圖像的寬度每次都是不同的(一些肖像,一些景觀)。 Googleing沒有幫助。所以這就是我想要的。任何幫助,將不勝感激。 enter image description hereAndroid TextView溢出

+0

您可以發佈您的佈局文件? – GrIsHu

+0

除了相對佈局外,佈局文件中沒有任何內容。一切都是動態添加的。 – Bhaijaan

+0

你是否動態添加'TextView'?如果是,則發佈該代碼。 – GrIsHu

回答

4

嘗試這樣的,它可以幫助你

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

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:src="your image" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/imageView" 
     android:layout_alignRight="@+id/imageView" 
     android:layout_below="@+id/imageView" 
     android:layout_marginTop="16dp" 
     android:text="I am creating sort of an image gallery (with view flipper) wherein each view of viewflipper has an imageview and two textviews below it. " /> 

</RelativeLayout> 
+0

正是我想要的感謝! – Bhaijaan

+0

它好吧,你歡迎 – user2496783