DecorView的子FrameLayout

3

能否有人解释一下为什么我布局上DecorView的子项是一个FrameLayout,即使我没有定义它?

这是xml布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_general" >

<ImageView
    android:id="@+id/ivIKUGo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:src="@drawable/mainbutton_selector" />

<ImageView
    android:id="@+id/imageViewmoto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="150dp"
    android:src="@drawable/motto_buttonpage_hdpi" />

</RelativeLayout>

谢谢


这就是在Android中构建活动的方式,除了您的内容,活动还可以显示其他元素,例如操作栏。活动的内容将添加到具有android.R.id.content ID的FrameLayout中。 - user
@Luksprog 好的,我有另一个示例项目,其中DevorView的子项是LinearLayout,这个项目有什么不同吗? - pamgeo
我不太记得DecorView是如何构建的,但是你使用setContentView设置的布局会被添加到ID为android.R.id.contentFrameLayout中。你对DecorView感兴趣有什么特别的原因吗? - user
但是当我将此实现到我的项目中时,我发现在LinearLayout之前会得到android.R.id.content Framelayout。 - pamgeo
示例http://postimage.org/image/xsmgc20c1/和我的项目http://postimage.org/image/5tsal6ypd/实现了相同的库。 - pamgeo
显示剩余9条评论
1个回答

3
您如果使用正常主题,LinearLayout将位于DecorViewFrameLayout之间,用于存放Activity的内容。如果您使用NoTitleBar类型的主题,则不需要额外的LinearLayout,因此会将其删除,使内容FrameLayout成为DecorView的子级。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接