android中的TextView未将文本包装到下一行

android中的TextView未将文本包装到下一行,android,textview,Android,Textview,嗨,在我的应用程序中,我有一个注册表,当我将大文本设置为textview时,textview和edittext都面朝下,而不是将文本包装到下一行 下面是我试过的。 试试这个,使用weightSum <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="m

嗨,在我的应用程序中,我有一个注册表,当我将大文本设置为textview时,textview和edittext都面朝下,而不是将文本包装到下一行

下面是我试过的。



试试这个,使用
weightSum

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:padding="8dp"
        android:text="Register"
        android:textColor="#336633"
        android:textSize="25dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="5">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.30"
            android:padding="8dp"
            android:text="I"
            android:textSize="20dp" />

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.33"
            android:hint="FirstName" />

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.33"
            android:hint="LastName" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:padding="8dp"
            android:gravity="center"
            android:maxLines="2"
            android:text="pledged that I will Ride"
            android:textSize="20dp" />

    </LinearLayout>
</LinearLayout>

我认为您正在寻找一种解决方案,将文本包装在您的编辑文本中


您不能按所需方式将
文本视图中的文本移动到下一行。如果将其中的文本移动到下一行,它将从它所在的位置(您在这里的体验)开始下一行

最好的解决方案是将最后一个
文本视图
放在
线性布局
之外

移动

。。。
...
...

在内部
线性布局之外

如果减少文本的ems,那么它可以帮助您

例如,
android:ems=“(大小)”


注意:大小必须以像素为单位。

承诺我将乘坐的textview在哪里?固定textview的宽度。因此,它会自动将文本换行到下一行。@Rohit5k2我已经编辑了问题,请检查。@Bhoomika我担心你的技巧行不通。@Bhoomika它不起作用。添加--android:gravity=“center”我正在将大文本设置为文本查看它没有将文本换行到下一行这意味着什么。我刚刚添加了权重和,以便正确显示。请您详细解释一下@ShivLeelalarge文本在某种意义上保证我会骑马。你想在名字文本下一行中“will ride”吗@ShivLeelaits现在进入一个新行。我需要在edittextIt之后继续textview。它将进入该文本视图中的新行->全文。你不想把它完全移到下面是另一回事。你为什么不多用一个文本视图,把它放在内部线性布局之外呢。是的,我不想整行移到新行。我的计划是根据屏幕的宽度来设计它,它应该包装并拆分成几行。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:padding="8dp"
        android:text="Register"
        android:textColor="#336633"
        android:textSize="25dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="5">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.30"
            android:padding="8dp"
            android:text="I"
            android:textSize="20dp" />

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.33"
            android:hint="FirstName" />

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.33"
            android:hint="LastName" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:padding="8dp"
            android:gravity="center"
            android:maxLines="2"
            android:text="pledged that I will Ride"
            android:textSize="20dp" />

    </LinearLayout>
</LinearLayout>
...
...
...
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="pledged that I"
    android:textSize="20dp"
    android:padding="8dp"/>
</LinearLayout>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="will Ride"
    android:textSize="20dp"
    android:padding="8dp"/>
</LinearLayout>