在android中实现流程布局中的新行

在android中实现流程布局中的新行,android,flowlayout,Android,Flowlayout,我的问题与此类似 Iam使用Flowlayout创建标记云,我能够创建它,Iam膨胀文本视图,因为文本可以变化,我看到所有使用新行的示例都有固定的布局xml。如何在文本视图中实现新行。运行时,FlowLayout.LayoutParams对象上的新行标志似乎不可修改。您需要修改库本身以添加此功能,或者在需要使用换行xml扩展TextView时保留一个单独的布局文件 如果您希望将文本分成两行并继续使用FlowLayout,则需要将两个单独的文本视图充气,一个用于第一行,另一个用于第二行。您还需要

我的问题与此类似


Iam使用Flowlayout创建标记云,我能够创建它,Iam膨胀文本视图,因为文本可以变化,我看到所有使用新行的示例都有固定的布局xml。如何在文本视图中实现新行。

运行时,
FlowLayout.LayoutParams
对象上的新行标志似乎不可修改。您需要修改库本身以添加此功能,或者在需要使用换行xml扩展TextView时保留一个单独的布局文件

如果您希望将文本分成两行并继续使用FlowLayout,则需要将两个单独的文本视图充气,一个用于第一行,另一个用于第二行。您还需要手动计算屏幕上可容纳的文本量来完成此操作。

父布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.example.customns"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
tools:context=".CustomActivity" 
android:orientation="vertical">
<com.example.customns.FlowLayout
    android:id="@+id/loadlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="horizontal"
    >
</com.example.customns.FlowLayout>
</RelativeLayout>

要在父级中充气的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res/com.example.customns"
android:id="@+id/buttonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"  
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"  
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" 
android:background="@color/blue"
android:orientation="horizontal" >

<TextView    
     app:layout_newLine="true"
    android:id="@+id/text1"
    android:layout_width="wrap_content"       
    android:layout_height="wrap_content" 
     android:layout_marginTop="5dp"
     android:layout_marginBottom="5dp"  
     android:layout_marginLeft="5dp"
     android:layout_marginRight="5dp"     
    android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

layout_newLine在充气布局中不起作用,如果父布局中有所有textview,则充气布局会起作用。有什么建议吗