0

This is the XML layout for the TextView:

<LinearLayout 
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ScrollView 
        android:id="@+id/scrollview1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:fillViewport="true">
<TextView
        android:id="@+id/tv1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1.0"
        android:typeface="sans"
        android:layout_gravity="center_vertical|left"
        android:textSize="17sp" 
        />
</ScrollView>
</LinearLayout>

The text is being sourced from a .txt file containing 431 lines. But the first 81 lines are out of the screen ( off the top edge of the screen). What am I doing wrong?

The code reading the .txt file:

    String l="";
    TextView two=(TextView)findViewById(R.id.tv1);
    InputStream is =getAssets().open("codes1.txt");
    InputStreamReader iz=new InputStreamReader(is);
    BufferedReader bis = new BufferedReader(iz);
    try {
        String text="";
        while((l=bis.readLine())!=null) {
            text=text+l+"\n";
        }
        two.setText(text);
        two.setMovementMethod(new ScrollingMovementMethod());
    } catch(Exception a) { Log.d("error is "+a.toString(),"error"); }
4

1 回答 1

1

好的,所以内容在那里,尝试从删除android:layout_gravity="center_vertical|left"TextView删除这一行

two.setMovementMethod(new ScrollingMovementMethod());从你的java文件。

于 2013-06-05T18:03:50.493 回答