Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android复杂布局线性和相对_Android_Performance_Android Layout_Layout_Android Linearlayout - Fatal编程技术网

Android复杂布局线性和相对

Android复杂布局线性和相对,android,performance,android-layout,layout,android-linearlayout,Android,Performance,Android Layout,Layout,Android Linearlayout,我必须实现如图所示的布局,我不知道实现所需设计的最佳组合。 我正在为7英寸的平板电脑设计,希望它在10英寸的平板电脑上有很好的延展性 我假设像1,2,3,4,5这样的布局是线性布局,对吗 *活动布局是什么?我尝试了RelativeLayout,但无法在布局1、2和3之间分配宽度(使用android:layout_weight) *我尝试了整个活动的水平线性布局,但无法将页眉和页脚布局正确添加到主水平线性布局 我阅读了文档和教程,但找不到这个复杂设计的线索,请帮助 另外,嵌套布局的性能影响是什么

我必须实现如图所示的布局,我不知道实现所需设计的最佳组合。 我正在为7英寸的平板电脑设计,希望它在10英寸的平板电脑上有很好的延展性

我假设像1,2,3,4,5这样的布局是线性布局,对吗

*活动布局是什么?我尝试了RelativeLayout,但无法在布局1、2和3之间分配宽度(使用android:layout_weight)

*我尝试了整个活动的水平线性布局,但无法将页眉和页脚布局正确添加到主水平线性布局

我阅读了文档和教程,但找不到这个复杂设计的线索,请帮助

另外,嵌套布局的性能影响是什么


谢谢,

您可以尝试类似的方法,正如其他人所说,在这个级别上,您不会有性能问题

<?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:orientation="vertical"
android:weightSum="1" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"
    android:background="@android:color/holo_orange_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.8"
        android:background="@android:color/black" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.6"
    android:background="@android:color/holo_blue_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/holo_purple"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.2"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.3"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.4"
        android:background="@android:color/holo_red_dark"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.33"
            android:background="@android:color/black" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="0.4"
        android:background="@android:color/darker_gray"
        android:orientation="vertical"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />

        <View
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:background="@android:color/black" />
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"
    android:background="@android:color/holo_green_light"
    android:orientation="horizontal"
    android:weightSum="1" >

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.2"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.3"
        android:background="@android:color/black" />

    <View
        android:id="@+id/view2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.5"
        android:background="@android:color/black" />
</LinearLayout>

</LinearLayout>


这就是我们的目的。:-)查看本文:

您将需要线性和相对布局的组合。要在水平和垂直方向上对块进行分组,可以使用LinearLayout,要放置这些组,可以使用linear layout并相应地调整权重,也可以使用relative并相互设置权重。

根据我的经验,嵌套布局的性能影响可以忽略不计。另外,你在这里真的没有太多的视图,所以我不会担心,除非你在很多视图中有一些复杂的动画。保罗,你是对的,博文显示这是正确的方式。我将测试它和反馈,但我现在急于进行实验。谢谢在我的平板电脑上测试,效果很好,我会用我需要的小部件和反馈替换视图,我想你的方式会在大屏幕平板电脑上很好地延伸。非常感谢您所做的努力。@Montaro de nada Montaro:-))为什么整个布局在ADT designer中被裁剪,而不是在我使用eclipse/ubuntu的物理平板电脑上显示得很好