Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android textview没有正确包装大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下xml来显示listView中的行.我希望带有id rowCreatedAt的TextView很好地包裹但它永远不会,只显示1行.我在其他问题中尝试了大多数解决方案并将其添加代码中,但它仍然无效.谁能告诉我为什么……?

 我想避免为textview设置确切的大小.

   换句话说,为什么当宽度/高度设置为fill_parent时,rowCreatedAt textView不会包装文本,而其他textViews包装文本就好了?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_108_11845@as.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_margin="5dp"
    android:layout_marginBottom="5dp" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/rowUserImage"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:src="@drawable/twitter_icon" 
            android:layout_margin="5dp"/>

        <TextView
            android:id="@+id/rowCreatedAt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10dp"
            android:textColor="#ff696969"
            android:ellipsize="none"
            android:singleLine="false"
            android:scrollHorizontally="false"
            android:layout_weight="1"
            android:maxLines="100"
            android:text="aaaaaaaaaaaaaaabbbbbbbbbbbbbb" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/rowUserName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:text="username"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/rowText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:text="status text" />
    </LinearLayout>

</LinearLayout>

解决方法

<TextView
            android:id="@+id/rowCreatedAt"
             android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="10dp"
            android:textColor="#ff696969"
            android:ellipsize="none"
            android:singleLine="false"
            android:scrollHorizontally="false"
            android:layout_weight="1"
            android:maxLines="100"
            android:text="aaaaaaaaaaaaaaabbbbbbbbbbbbbb" />

将android:layout_width =“fill_parent”更改为android:layout_width =“200dp”

大佬总结

以上是大佬教程为你收集整理的android textview没有正确包装全部内容,希望文章能够帮你解决android textview没有正确包装所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。