【问题标题】:What is the parent layout of All Root layout in AndroidAndroid中All Root布局的父布局是什么
【发布时间】:2014-08-29 05:34:09
【问题描述】:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" 
    />
</LinearLayout> 

我的 Java 代码:

linearLayout=(LinearLayout) findViewById(R.id.linearLayout);
System.out.println(linearLayout.getParent());

它会告诉你 framelayout 是线性布局的父布局。请告诉 1.框架布局是线性布局的父布局如何? 2. 默认窗口有框架布局?

请帮助我。提前谢谢。

【问题讨论】:

  • ad 1 FrameLayout 可以是任何 View 的父级,包括 LinearLayout,ad 2 检查它:Window.getDecorView()

标签: android android-linearlayout parent-child android-framelayout gravity


【解决方案1】:

没错,DecorView 将使用FrameLayout 来存储应用程序设置的所有内容。可以阅读PhoneWindow的源码

【讨论】:

  • 谢谢suitaianshi。你能给我一个链接/来源,这样我就可以得到更多关于decorview的知识。理论内容不是程序性内容
  • 抱歉,我找不到一篇(足够好)关于它的文章。但我一直认为源代码是最好的教程。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-28
相关资源
最近更新 更多