Android 单个xml文件中的多个布局

Android 单个xml文件中的多个布局,android,Android,我只想在一个xml文件中使用多个布局。在这将有一个绝对布局,应该在水平滚动。作为一个初学者,我不知道如何实现它 需要你的帮助,朋友们 xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/aagr_background2" a

我只想在一个xml文件中使用多个布局。在这将有一个绝对布局,应该在水平滚动。作为一个初学者,我不知道如何实现它

需要你的帮助,朋友们

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/aagr_background2"
android:orientation="vertical" >

<fragment
    android:id="@+id/adview153613"
    android:name="com.sentientit.theiWedplanner.Fragadmob"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

<RelativeLayout
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="@drawable/aanavigationbar" >

    <Button
        android:id="@+id/back"
        android:layout_width="70dp"
        android:layout_height="50dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="3dp"
        android:layout_x="8px"
        android:layout_y="3px"
        android:background="@drawable/custom_btn_breaker_bay"
        android:text="Back"
        android:textColor="#ffffff"
        android:textSize="20sp" />

    <Button
        android:id="@+id/home"
        android:layout_width="50px"
        android:layout_height="30px"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/back"
        android:layout_marginRight="46dp"
        android:background="@drawable/home1"
        android:paddingBottom="12px"
        android:paddingTop="10px"
        android:visibility="gone" />

</RelativeLayout>

<AbsoluteLayout
    android:layout_width="fill_parent"
    android:layout_height="61dp" >
    <AbsoluteLayout
        android:layout_width="fill_parent"
        android:layout_height="61dp"
        android:layout_x="120dp"
        android:layout_y="35dp" >
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="38dp"
            android:layout_y="30dp"
            android:text="-   Kid Seated"
            android:textColor="#000000"
            android:textSize="13dp"
            android:typeface="serif" >
        </TextView>

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="6dp"
            android:layout_y="28dp"
            android:src="@drawable/kid" >
        </ImageView>
    </AbsoluteLayout>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="437dp"
        android:layout_y="3dp"
        android:src="@drawable/add11_table" />

    <Button
        android:id="@+id/button3"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="48dp"
        android:layout_y="4dp"
        android:text="Line"
        android:textSize="20sp" />

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="128dp"
        android:layout_y="4dp"
        android:text="circle"
        android:textSize="20sp" />

    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="212dp"
        android:layout_y="6dp"
        android:text="vshape"
        android:textSize="20sp" />

</AbsoluteLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/table"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"

            android:orientation="vertical" >
        </LinearLayout>
    </HorizontalScrollView>
</ScrollView>
xmlns:ads=”http://schemas.android.com/apk/lib/com.google.ads"
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”
android:background=“@drawable/aagr_background2”
android:orientation=“vertical”>


提前感谢您

是的,您可以使用
在单个XML中使用多个布局

下面是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/app_background"
    android:orientation="vertical" >

    <include layout="@layout/actionbar_main" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/img_rest_pic"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight=".35"
            android:src="@drawable/upload_image" />
     </LinearLayout>
 </LinearLayout>

是的,您可以使用
在单个XML中使用多个布局

下面是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/app_background"
    android:orientation="vertical" >

    <include layout="@layout/actionbar_main" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/img_rest_pic"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight=".35"
            android:src="@drawable/upload_image" />
     </LinearLayout>
 </LinearLayout>

不确定你是否在寻找这条路线,但我只是试了一下。。。。。每当您希望在屏幕底部修复布局时,请确保使用“权重”属性,即如果您希望在屏幕底部修复按钮,请将android:layout\u height=“0dp”和layout\u weight=“1”对于xml中的其他主要版面和必须固定在底部的to按钮,请使用android:layout\u height=“wrap\u content”和layout\u weight=“0”这就是诀窍所在(如果我弄得很难理解,请道歉……只需简单地说“玩重量和高度属性”)


不确定您是否正在寻找此对齐方式,但我只是尝试一下。。。。。每当您希望在屏幕底部修复布局时,请确保使用“权重”属性,即如果您希望在屏幕底部修复按钮,请将android:layout\u height=“0dp”和layout\u weight=“1”对于xml中的其他主要版面和必须固定在底部的to按钮,请使用android:layout\u height=“wrap\u content”和layout\u weight=“0”这就是诀窍所在(如果我弄得很难理解,请道歉……只需简单地说“玩重量和高度属性”)




对不起,我听不懂你的问题。你能更清楚地解释一下吗?在我的代码中有一个绝对布局。布局中的对象在页面的顶部,我需要它在页面的底部,我该怎么做?我的问题绝对布局在android中是非常古老的技术。不要使用它,而是使用相对或框架布局来实现您的目标,同时从绝对布局更改为相对布局java文件中应该做的所有更改是什么。你能更清楚地解释一下吗?在我的代码中有一个绝对布局。布局中的对象在页面的顶部,我需要它在页面的底部,我该怎么做?我的问题绝对布局在android中是非常古老的技术。不要使用它,当从绝对布局更改为相对布局时,所有的更改都应该在java文件中完成感谢您的回答在我的情况下我需要绝对布局组件应该移动到页面底部如何实现它我的问题您可以查看我的代码布局非常复杂,是所有组件都在同一个xml中还是在不同的xml中?你需要写一点复杂的东西。它在同一个xml文件中。然后你可以使用布局的权重和来管理这些位置,就像在任何视图中一样:android:layout\u weight=“0.2”我应该把它放在哪里你会说我给定代码的位置吗谢谢你的回答在我的情况下我需要绝对布局组件应该移到页面底部我如何实现它我的问题你可以查看我的代码你的布局非常复杂,如果所有组件都在同一个xml中或在不同的xml中,请编写其稍微复杂的xml文件。如果在同一个xml文件中,则可以使用布局的权重和来管理这些位置,就像在任何视图中一样:android:layout\u weight=“0.2”我应该把它放在哪里你会说我给定代码的位置吗谢谢它的工作我需要对它做一些小改动现在它工作了谢谢它的工作我需要对它做一些小改动现在它工作了\
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#fff"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/adview153613"
        android:name="com.sentientit.theiWedplanner.Fragadmob"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"  >

        <Button
            android:id="@+id/back"
            android:layout_width="70dp"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="3dp"
            android:layout_x="8px"
            android:layout_y="3px"
            android:text="Back"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <Button
            android:id="@+id/home"
            android:layout_width="50px"
            android:layout_height="30px"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/back"
            android:layout_marginRight="46dp"
            android:paddingBottom="12px"
            android:paddingTop="10px"
            android:visibility="gone" />
    </RelativeLayout>



    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical" >

        <HorizontalScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/table"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >
            </LinearLayout>
        </HorizontalScrollView>
    </ScrollView>

    <AbsoluteLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" >

        <AbsoluteLayout
            android:layout_width="fill_parent"
            android:layout_height="61dp"
            android:layout_x="120dp"
            android:layout_y="35dp" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_x="38dp"
                android:layout_y="30dp"
                android:text="-   Kid Seated"
                android:textColor="#000000"
                android:textSize="13dp"
                android:typeface="serif" >
            </TextView>

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_x="6dp"
                android:layout_y="28dp" >
            </ImageView>
        </AbsoluteLayout>

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="437dp"
            android:layout_y="3dp" />

        <Button
            android:id="@+id/button3"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="48dp"
            android:layout_y="4dp"
            android:text="Line"
            android:textSize="20sp" />

        <Button
            android:id="@+id/button1"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="128dp"
            android:layout_y="4dp"
            android:text="circle"
            android:textSize="20sp" />

        <Button
            android:id="@+id/button2"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_x="212dp"
            android:layout_y="6dp"
            android:text="vshape"
            android:textSize="20sp" />
    </AbsoluteLayout>
</LinearLayout>