以前は、ファイル res\layout\main.xml がありました。
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.98"
android:fillViewport="true"
android:scrollbars="vertical" >
<TextView
android:id="@+id/showmsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:textColor="@color/textshowmsgcolor"
android:textSize="10dp" />
</ScrollView>
TextView を動的に作成する必要があるため、res\layout\main.xml が作成されました。
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.98"
android:fillViewport="true"
android:scrollbars="vertical" >
<LinearLayout
android:id="@+id/linearLayout2"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
これは私の MainActivity.java です:
TextView tv = new TextView(this);
tv.setBackgroundColor(Color.parseColor("#112222"));
tv.setId(windows.size()+100);
tv.setTextSize(10);
tv.setTextColor(Color.parseColor("#FFFFFF"));
tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
((LinearLayout) linearLayout2).addView(tv);
ウィンドウは動的に作成されます。残念ながら、ウィンドウがテキストでいっぱいになると、スクロールは動きません。古い設定を Java コードに書き込む方法を教えてください。