Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android xml中添加两个端到端的文本视图_Android_Textview - Fatal编程技术网

在android xml中添加两个端到端的文本视图

在android xml中添加两个端到端的文本视图,android,textview,Android,Textview,我想在另一个textview的末尾添加一个textview,即不是在下一行,而是在xml文件中上一个textview的结尾处。就像: | <TextView1><TextView2> | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb | 我的xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmln

我想在另一个textview的末尾添加一个textview,即不是在下一行,而是在xml文件中上一个textview的结尾处。就像:

| <TextView1><TextView2>    |


| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb    |
我的xml文件:

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

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
        android:ellipsize="none"/>

    <TextView
        android:id="@+id/date"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="bbb" />

</LinearLayout>
但未显示文本bbb。有人能帮忙吗?

使用加权和

我已经提供了50%的空间,您可以根据您的要求进行更改

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

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
            android:ellipsize="none"
            android:layout_weight=".5"/>

        <TextView
            android:id="@+id/date"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="bbb"
            android:layout_weight=".5" />

    </LinearLayout>
根据要求

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" 
    >

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
        android:ellipsize="none"
        />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="bbb"
        android:layout_alignRight="@id/textView"
         />

</LinearLayout>
</HorizontalScrollView>
使用权重和

我已经提供了50%的空间,您可以根据您的要求进行更改

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

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
            android:ellipsize="none"
            android:layout_weight=".5"/>

        <TextView
            android:id="@+id/date"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="bbb"
            android:layout_weight=".5" />

    </LinearLayout>
根据要求

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" 
    >

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
        android:ellipsize="none"
        />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="bbb"
        android:layout_alignRight="@id/textView"
         />

</LinearLayout>
</HorizontalScrollView>
使用以下命令

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

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ellipsize="none"
            android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
            />

        <TextView
            android:id="@+id/date"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="bbb" />

    </LinearLayout>
使用以下命令

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

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ellipsize="none"
            android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
            />

        <TextView
            android:id="@+id/date"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="bbb" />

    </LinearLayout>

这是因为您提供了android:ellipsize=none作为none,并为textView提供了很长的文本


只需提供android:ellipsize=end,您就可以看到第二个文本视图。

这是因为您提供了android:ellipsize=none作为none,并为textView提供了很长的文本

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

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
    android:ellipsize="none"/>

<TextView
    android:id="@+id/date"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="bbb" />

 </LinearLayout>

只需提供android:ellipsize=end,您就可以看到第二个文本视图。

使用RelativeLayout并让您的aaaa。。。文本视图与bbb文本视图的左侧对齐。如果需要多行,可以删除maxLines或将其设置为其他值

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

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 
    android:ellipsize="none"/>

<TextView
    android:id="@+id/date"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="bbb" />

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

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/date"
        android:ellipsize="none"
        android:maxLines="1"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="bbb" />

</RelativeLayout>

使用相对论,让你的aaaa。。。文本视图与bbb文本视图的左侧对齐。如果需要多行,可以删除maxLines或将其设置为其他值

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

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/date"
        android:ellipsize="none"
        android:maxLines="1"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="bbb" />

</RelativeLayout>


只需使用一个文本视图,在cod中使用append方法,并在第二个文本前添加一些空格即可:

只需使用一个文本视图,在cod中使用append方法,并在第二个文本前添加一些空格即可:

如果您的文本有那么长,那你为什么要把这两个文本框并排放在一起呢?你真的想保持省略号为none吗?因为如果这是您的要求,那么就不可能将两个文本视图保持在同一行,如果不是,那么请查看我的答案。@GAMA..不是并排而是端到端。如果您的文本可能有那么长,那么为什么您要并排放在两个文本框中?您真的想保持省略号为“无”吗?因为如果这是你的要求,那么就不可能将两个文本视图保持在同一行,如果不是,请查看我的答案。@GAMA..不是并排而是端到端。他想让文本视图并排出现。上面的代码将把seconde textView放在第一行下面。bbb转到下一行。它应该就在a的结尾处。他希望textView并排出现。上面的代码会将seconde textView放在第一行的下面。bbb转到下一行。它应该在a的后面,在这里a的结尾在这种情况下b的结尾只出现在第一行。否。。我只希望不同文本视图中的新文本不会从下一行开始,就像方向是垂直的一样。它应该从第一个文本视图文本结束的同一行开始。您需要滚动视图以查看bbb,或者必须省去AAAA。。或者你必须读一些AAAAA的文字。。。。到下一行。。你喜欢什么?在这种情况下,b只排在第一线。不。。我只希望不同文本视图中的新文本不会从下一行开始,就像方向是垂直的一样。它应该从第一个文本视图文本结束的同一行开始。您需要滚动视图以查看bbb,或者必须省去AAAA。。或者你必须读一些AAAAA的文字。。。。到下一行。。你喜欢什么?如果我不想要一行呢?如果我想在一个字符串的末尾加上两行或三行,这取决于手机的分辨率,那该怎么办?如果我不想把它放在一行呢?如果我想在一个字符串的末尾加上两行或三行,这取决于手机的分辨率,该怎么办?