2013-10-08 37 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