<分区>
我有一张背景图片:
android:background="@drawable/bg">
和一个 TextView:
final TextView theTimer = new TextView(this);
如果我使用 setContentView,我只能将其中一个放在屏幕上。 我怎样才能让他们同时参加一项 Activity ?
<分区>
我有一张背景图片:
android:background="@drawable/bg">
和一个 TextView:
final TextView theTimer = new TextView(this);
如果我使用 setContentView,我只能将其中一个放在屏幕上。 我怎样才能让他们同时参加一项 Activity ?
最佳答案
做这样的事情-
my_layout.xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg">
</LinearLayout>
Activity code
setContentView(R.layout.my_layout);
final TextView theTimer = new TextView(this);
LinearLayout ll = (LinearLayout)findViewByID(R.id.ll);
ll.addView(theTimer);
关于java - Android 中的多个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30592428/