在XML中组合两个LinearLayouts

时间:2014-06-14 17:21:20

标签: android xml android-layout

所以基本上我试图在xml for android中结合两个linearlayouts。我的问题是,当我将第二个xml文件放在第一个使用时使用:

  <include
        android:id="@+id/name_goes_here"
        layout="@layout/name_goes_here" />
它吹出的比例超出了第一个。基本上在下面的突出显示部分有控件xml我试图把我的按钮xml文件代替。但是,我的错误是当我编辑时

我的第一个xml(activity_main.xml)如下所示:

First xml

现在xml文件如下所示:(下半部分在一个名为controls的单独xml文件中突出显示。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              xmlns:seekarc="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"

              android:paddingBottom="@dimen/activity_vertical_margin"
              android:paddingLeft="@dimen/activity_horizontal_margin"
              android:paddingRight="@dimen/activity_horizontal_margin"
              android:paddingTop="@dimen/activity_vertical_margin"
              tools:context=".MainActivity" >

    <FrameLayout
        android:id="@+id/seekArcContainer"
        android:layout_width="350dp"
        android:layout_height="520dp"
        android:layout_weight="1" >

        <com.triggertrap.seekarc.SeekArc
            android:id="@+id/seekArc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:padding="30dp"
            seekarc:rotation="180"
            seekarc:startAngle="0"
            seekarc:sweepAngle="360"
            seekarc:touchInside="true"
            seekarc:arcColor="#ff5ac3ff"
            seekarc:progressColor="#ffff3a35"/>

        <TextView
            android:id="@+id/seekArcProgress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="0"
            android:textSize="40sp" />
    </FrameLayout>



    <include
        android:id="@+id/controls"
        layout="@layout/controls" />

</LinearLayout>

我试图用它代替控件。这是buttons.xml

enter image description here

在这种情况下不确定如何实现更改,因为include标记导致xml文件相互重叠

这是buttons.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:weightSum="1">

    <TableLayout android:id="@+id/tableLayout1"
                 android:layout_height="wrap_content"
                 android:layout_width="fill_parent" />

    <Button
        android:id="@+id/block_button"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center_vertical"
        android:layout_weight="0.09"
        android:background="#ff5ac3ff"
        android:drawableLeft="@drawable/ic_action"
        android:gravity="center_horizontal|center_vertical"
        android:text="@string/block_apps"
        android:textSize="22sp" />

    <Button
        android:id="@+id/security_settings_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ff5ac3ff"
        style="?android:attr/borderlessButtonStyle"
        android:layout_weight="0.09"
        android:drawableLeft="@drawable/ic_settings"
        android:gravity="center_horizontal|center_vertical"
        android:text="@string/security_settings"

        android:textSize="22sp"/>

    <Button
        android:id="@+id/blacklist_whitelist_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ff5ac3ff"
        style="?android:attr/borderlessButtonStyle"
        android:drawableLeft="@drawable/ic_blacklist_red"
        android:gravity="center_horizontal|center_vertical"
        android:text="@string/blacklist_whitelist"
        android:textSize="22sp"
        android:layout_weight="0.09"/>


</LinearLayout>

1 个答案:

答案 0 :(得分:1)

相关问题