如何使多個textview在屏幕的某些不同部分垂直滾動?使textview垂直滾動
<ImageView android:id="@+id/imageView" android:layout_width="200dp" android:layout_height="200dp" android:src="@drawable/girl1" /> <TextView android:layout_width="200dp" android:layout_height="200dp" android:id="@+id/textview" android:maxLines="8" android:scrollbars="vertical" android:layout_alignTop="@+id/imageView" android:layout_toEndOf="@+id/imageView" android:layout_toRightOf="@+id/imageView"></TextView> </RelativeLayout> TextView intro; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_meet_our_team); TextView txtview=(TextView)findViewById(R.id.textview); String text="I like programming in Android. This tip shows you how to make a TextView scrollable in Android."; txtview.setText(text); intro.setMovementMethod(new ScrollingMovementMethod()); } }
我收到以下錯誤:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setMovementMethod(android.text.method.MovementMethod)' on a null object reference
at com.example.cepl_pc.trial.MeetOurTeam.onCreate
如果我想讓我有3個圖像瀏覽和3個文字瀏覽並希望他們滾動,我該怎麼辦? –
在這種情況下,我只是將listview用於多行,您的行將具有imageView和textview,不會限制視圖,您可以添加與imageViews&textViews一樣多的文件。 – Anurag