Android文本视图溢出
我正在创建一种图像库(带有view flipper),其中viewflipper的每个视图下都有一个imageview和两个TextView。我想要的是根据imageviews的宽度调整这些文本视图的宽度。这些imageview和文本是动态添加到viewflipper的,因此无法在xml中调整宽度。此外,图像的宽度每次都不同(有些是纵向的,有些是横向的)。谷歌搜索没有帮助。这就是我想要的。任何帮助都将不胜感激。试试这个Android文本视图溢出,android,textview,overflow,Android,Textview,Overflow,我正在创建一种图像库(带有view flipper),其中viewflipper的每个视图下都有一个imageview和两个TextView。我想要的是根据imageviews的宽度调整这些文本视图的宽度。这些imageview和文本是动态添加到viewflipper的,因此无法在xml中调整宽度。此外,图像的宽度每次都不同(有些是纵向的,有些是横向的)。谷歌搜索没有帮助。这就是我想要的。任何帮助都将不胜感激。试试这个 tv.setMaxLines(2); tv.setEllipsize(Tex
tv.setMaxLines(2);
tv.setEllipsize(TextUtils.TruncateAt.END);
更多文档:试试这个
tv.setMaxLines(2);
tv.setEllipsize(TextUtils.TruncateAt.END);
更多文档:像这样试试,它可能会对您有所帮助
<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>
像这样试试,可能会对你有所帮助
<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>
您可以发布布局文件吗?布局文件中除了相对布局外没有其他内容。所有内容都是动态添加的。是否动态添加TextView
?如果是,则发布该代码。您可以发布布局文件吗?布局文件中除了相对布局之外没有其他内容。所有内容都是动态添加的。是否动态添加TextView
?如果是,则发布该代码。