2013-02-01 62 views
1

我有一个textview,当它有两行以上的文本时,第二行变成第一行,下面有一行可用,第一行不应该是可见的。这是可能的android的textview?Textview with lines scroll

回答

1

试试这个

<TextView 
    android:id="@+id/TextView01" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:singleLine="false" 
    android:maxLines="3" 
    android:scrollbars="vertical" 
    android:textColor="@android:color/secondary_text_dark_nodisable" 
> 

代码

TextView textView = (TextView)findViewById(R.id.TextView01); 
textView.setMovementMethod(ScrollingMovementMethod.getInstance()); 
0

是可能的。创建高度为2 * text_line_height的scrollView。并在里面添加TextView。其中text_light _height与textSize成比例。所以只需尝试一些组合,比如14sp vs 8o dp。 好处是sp/dp会为所有设备大小提供相同的行为。

0

是的,看看。

<ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" > 


      <TextView 
       android:id="@+id/TextView01" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:singleLine="false" 
       android:textSize="20dp" 
       android:text="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" 
       /> 
    </ScrollView>