我正在玩 Google I/O 2011 的iosched应用程序。查看 ScheduleFragment,我正在测试Workspace子项的不同视图,用于来回翻转页面。但是,我无法让我的孩子的意见填补父母。我添加了几种背景颜色和一些填充以显示所有内容的布局。这是我的测试...
我像这样在 fragment_schedule.xml 中的“工作区”项中添加了红色背景色...
android:background="#cc0000"
然后,我没有为子视图使用blocks_content.xml,而是创建了自己的pending_content.xml,它只是一个绿色背景的LinearLayout(高度为fill_parent)和一个蓝色背景的TextView(高度也为fill_parent)文本行。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00cc00"
android:padding="5dip"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/text_view"
android:background="#0000cc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Pending Content"
android:textColor="#ffffff"
/>
</LinearLayout>
我添加我的视图,就像 I/O 应用程序有“天”一样......
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_schedule, null);
mWorkspace = (Workspace) root.findViewById(R.id.workspace);
ShootView view = new ShootView();
view.index = mViews.size();
view.rootView = (ViewGroup) inflater.inflate(R.layout.pending_content, null);
view.label = "Pending";
mWorkspace.addView(view.rootView);
mViews.add(view);
这是我在设备上查看时看到的内容:
您会看到红色的 Workspace 填充了可用的父空间,但绿色的 LinearLayout 没有。我错过了什么?