Android:如何处理长文本

Android:如何处理长文本,android,button,layout,view,textview,Android,Button,Layout,View,Textview,我如何在我的活动布局中处理我不知道有多长的长文本 我在文本视图中有这个文本,当它太长时,它会覆盖在我的按钮上 你说的是文本视图还是按钮?如果它是一个文本视图,你可以使用一个像下面这样的框文本视图。它会自动滚动,这样所有的文本都会显示出来 <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_heig

我如何在我的活动布局中处理我不知道有多长的长文本


我在文本视图中有这个文本,当它太长时,它会覆盖在我的按钮上

你说的是文本视图还是按钮?如果它是一个文本视图,你可以使用一个像下面这样的框文本视图。它会自动滚动,这样所有的文本都会显示出来

<TextView
            android:id="@+id/textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:ellipsize="marquee"

            android:lines="1"
            android:fadingEdge="horizontal"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:text="Your Looooooooooooooooooooooooooooooooooooooooong text!"
            android:textColor="#000"
            android:textSize="15dp" />
如果你想要一个可展开的文本视图,可以这样做。它有一个按钮来展开/折叠文本视图

在xml中

 <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"
    tools:context=".MainActivity" >

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="sdfsdfsdfsfasfdsfgdfgdfsgsdfgsdfgsdfgsdgsdgdsgdsgsdfgdsgdsfgsdfgsdgsdfgsdfgdsfgsdgdsgfsdgfsdgsdfgdsgdsfgdsfgdsfgsdghjghjghjghjghjfg"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </RelativeLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/relativeLayout1"
        android:text="Button" />

</RelativeLayout>

如果我没说错的话,你是在尝试用文本来适应视图。你能发布你的layout.xml或包含layout用户界面的图像吗?你能更具体地说明你到底想要什么吗?你想实现什么样的设计?这是可行的,但对用户不是很友好。用户按下“全部读取”按钮,然后文本展开,文本视图下的所有内容都向下移动,这难道不是一种方式吗?
 <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"
    tools:context=".MainActivity" >

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="sdfsdfsdfsfasfdsfgdfgdfsgsdfgsdfgsdfgsdgsdgdsgdsgsdfgdsgdsfgsdfgsdgsdfgsdfgdsfgsdgdsgfsdgfsdgsdfgdsgdsfgdsfgdsfgsdghjghjghjghjghjfg"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </RelativeLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/relativeLayout1"
        android:text="Button" />

</RelativeLayout>
boolean checkflag = true;// declare it as public

final RelativeLayout rl=(RelativeLayout)findViewById(R.id.relativeLayout1);


    Button b=(Button)findViewById(R.id.button1);
    final TextView text=(TextView)findViewById(R.id.textView1);



    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if(checkflag==true)
            {

            text.setSingleLine(true);
            checkflag=false;
            }

            else
            {
                text.setSingleLine(false);
                checkflag=true;
            }

        }
    });