Android: текстовое окно с вертикальным текстом прокрутки - программирование

Android: текстовое окно с вертикальным текстом прокрутки

Я нахожу сложное время, настраивая текст с вертикальным текстом прокрутки. В моем диалоговом окне у меня есть текстовое изображение с большим текстом, так как диалог - маленькое окно. Я хочу, чтобы текст textview прокручивал по вертикали, чтобы диалог выглядел хорошо. Ниже мой xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FFFFFF" >

    <ImageView
        android:id="@+id/fbcancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/fbcancel" />

    <EditText
        android:id="@+id/fbedittext"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="33dp"
        android:background="@drawable/roundcorners"
        android:ems="10"
        android:gravity="center"
        android:hint="@string/fbhint"
        android:lines="6"
        android:paddingRight="5dp"
        android:scrollHorizontally="true" />
    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="80dp"
        android:layout_height="250dp"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@+id/fbedittext" >

        <Spinner
            android:id="@+id/spinner"
            android:layout_width="50dp"
            android:layout_height="30dp"
            android:layout_alignLeft="@+id/fbshare"
            android:layout_alignRight="@+id/fbshare"
            android:layout_below="@+id/fbshare"
            android:layout_marginTop="16dp"
            android:drawSelectorOnTop="true"
            android:entries="@array/fblist" 

            android:visibility="gone"/>

        <ImageView
            android:id="@+id/fbpeople"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/fbshare"
            android:layout_alignRight="@+id/fbshare"
            android:layout_below="@+id/fbshare"
            android:layout_marginTop="16dp"
            android:background="@drawable/people"
            android:drawSelectorOnTop="true" />

        <ImageView
            android:id="@+id/fbshare"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="65dp"
            android:src="@drawable/newfb" />
    </RelativeLayout>



<ScrollView android:id="@+id/textAreaScroller" 
    android:layout_width="fill_parent" 
        android:layout_height="173px" 
        android:layout_x="0px" 
        android:layout_y="25px" 

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/fbedittext"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/fbedittext"
        android:layout_marginTop="22dp"
        android:lines="7"
        android:scrollbars="vertical"
        android:text="@string/fbtext" />
</ScrollView> 
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/fbcancel"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:paddingRight="2dp"
        android:src="@drawable/askabud" />

</RelativeLayout>

Я попытался разместить вид прокрутки, но текстовое представление идет в неправильном положении. Любая помощь приветствуется.

4b9b3361

Ответ 1

1. Через XML

<ScrollView android:id="@+id/textAreaScroller" 
    android:layout_width="fill_parent" 
    android:layout_height="173px" 
    android:layout_x="0px" 
    android:layout_y="25px" 
    android:scrollbars="vertical">
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/fbedittext"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/fbedittext"
    android:layout_marginTop="22dp"
    android:lines="7"        
    android:text="@string/fbtext" />
</ScrollView>

Код 2.Via

ScrollView scroller = new ScrollView(this);
TextView tv=(TextView)findViewById(R.id.textView1);
scroller.addView(tv);

ИЛИ

Ввод следующих свойств внутри <TextView>

android:scrollbars = "vertical"

В коде

tv.setMovementMethod(new ScrollingMovementMethod());

Ответ 2

Попробуйте установить максимальную высоту в текстовом режиме, это может сработать для вас, как показано ниже

<TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="100dip" // change dip accordingly
        android:layout_alignLeft="@+id/fbedittext"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/fbedittext"
        android:layout_marginTop="22dp"
        android:lines="7"
        android:scrollbars="vertical"
        android:text="@string/fbtext" />

Ответ 3

Внутри вашего ScrollView добавьте еще один RelativeLayout и внутри этого RelativeLayout разместите свой TextView.