简单的ScrollView

最后更新于:2022-04-01 14:43:00

每天进步一点点 ~~~ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/ll" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > </LinearLayout> </ScrollView> ~~~ ~~~ package com.example.mylistview; import java.util.Random; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.LinearLayout; import android.widget.TextView; public class MainActivity extends Activity { private LinearLayout ll; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ll = (LinearLayout)this.findViewById(R.id.ll); Random rd = new Random(); for ( int i = 0 ; i < 70 ; i ++ ) { TextView tv = new TextView(this); tv.setText(String.valueOf(rd.nextInt(500))); ll.addView(tv); } } } ~~~
';