2017-07-07 43 views
-1

我wouldlike滾動在同一時間2的TextView:滾動2 TextView的在同一時間與Android工作室

代碼:

TextView text_A; 
TextView text_B; 

A=(TextView)findViewById(R.id.t1); 
B=(TextView)findViewById(R.id.t2); 

A.setMouvementMethod(new ScrollingMovementMethod()); 
B.setMouvementMethod(new ScrollingMovementMethod()); 

我如何更改作品這個代碼?

感謝您的幫助!

回答

1

你可以把你所有的文本視圖到LinearLayout中,然後把該佈局到ScrollView.For例如,

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:scrollbars="horizontal" android:id="@+id/ScrollView"> 

<LinearLayout 
     android:layout_width="fill_parent"      
     android:orientation="vertical" 
     android:id="@+id/linearLayout1" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center_vertical|center_horizontal"> 

    <TextView android:text="@string/textView1" 
     android:id="@+id/t1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
    </TextView> 

    <TextView android:text="@string/textView2" 
     android:id="@+id/t2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
    </TextView> 
</LinearLayout> 
</ScrollView> 

而且這種聯繫也試試, Try

+1

謝謝!這是完美的 ! – azzerty2017