android - 在另一个android布局中调用一个android布局来制作嵌套布局

标签 android android-layout

抱歉,我是 Android 新手

由于我的内容很大,我将创建一个 ScrollView。通过这种方式,我在 1 个文件中创建了内容的某些部分(我们将其称为 FirstLayout.xml),并将另一部分创建为 SeconedLayout.xml。现在我将在一个 XML 文件中调用它们。(Parent.xml)

但问题是,我不知道,我应该如何在我的 ScrollView 中调用它们?

这是代码

FirstLayout.xml

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
.
.
.
</AbsoluteLayout>

SeconedLayout.xml 是:

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
  ...
    </LinearLayout>

Parent.xml

可见

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >

<!-- Call FirstLayout  -->  


<!-- Call SecondLayout  -->
</ScrollView>

最佳答案

您应该使用包含标签:

<include 
    layout="@layout/SeconedLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

关于android - 在另一个android布局中调用一个android布局来制作嵌套布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16684483/

相关文章:

android - android 中的新 Activity 转换

android - 不能对 Switch 组件使用 setOnCheckedChangeListener

android - 唤醒 + Wifi 锁定无效

javascript - 在移动设备/平板电脑上触摸时,Slick Slider 自动停止播放

android - SQL数据库到android SQLite数据库

android - 如何在 android LinearLayout 中滚动?

android - 以编程方式设置渐变背景

android - 如何在Android.Equalizer中获取音频文件的频段级别

java - 无法运行简单的安卓计算器应用程序

android - 在 Android 上将 TextView 放在另一个 TextView 旁边以获得更长的文本