Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.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_Android Layout - Fatal编程技术网

Android 如何在复杂的布局中进行布局

Android 如何在复杂的布局中进行布局,android,android-layout,Android,Android Layout,我正试图找到一种在Android中布局以下布局的方法: 其中as(4)为背景色,背景色应居中于屏幕底部,且正好为屏幕宽度的1/3。(1) ,(2),(3)是图像,其中(1)和(2)应居中于(4)内,(3)应居中于(4)的右上角 没有什么对我有用:( 如何使用Android布局进行此操作 编辑: 我成功地创建了(1)+(2)+(4),但(3)没有成功。以下是我的代码: <LinearLayout android:id="@+id/layout4" a

我正试图找到一种在Android中布局以下布局的方法:

其中as(4)为背景色,背景色应居中于屏幕底部,且正好为屏幕宽度的1/3。(1) ,(2),(3)是图像,其中(1)和(2)应居中于(4)内,(3)应居中于(4)的右上角

没有什么对我有用:(

如何使用Android布局进行此操作

编辑:

我成功地创建了(1)+(2)+(4),但(3)没有成功。以下是我的代码:

    <LinearLayout
        android:id="@+id/layout4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="50dp"
        android:gravity="center"
        android:weightSum="1.0" >

        <LinearLayout
            android:id="@+id/layoutSaveShare_inner"
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:layout_weight="0.33"
            android:background="@color/light_blue"
            android:gravity="center"
            android:orientation="horizontal"
            android:weightSum="1.0" >

            <ImageView
                android:id="@+id/img1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.43"
                android:src="@drawable/btn1" />

            <ImageView
                android:id="@+id/img2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.43"
                android:src="@drawable/btn2" />
        </LinearLayout>
    </LinearLayout>


谢谢

下面的sudo代码怎么样:

<someParentLayout>
<____Layout android:weight="33">
     <child items>
</_____Layout>
<RelativeLayout android:weight="67"
      android:background="blah">
      <TextView android:id="@+id/center_reference"
            android:layout_height/width="0dp"
            android:layout_centerInParent="true"/>
      <Images 2 & 3 to the left and right of "center_reference"
            android:layout_centerVertical="true"/>
</RelativeLayout>
</someParentLayout>


你唯一需要试验的部分是#3,我不太确定。

谢谢,但我设法做到了这一部分…问题是(3)在我的绘图中。如果你想用文本描述的方式来描述它,那会不会将图像的右半部分从屏幕上移开?不会在屏幕中居中,仅占屏幕的1/3-因此(3)仍在智能手机屏幕内ohh,1/3宽度?高度?两者都有?您不能将视图放置在xml布局中3的中心。我不需要。(4)在屏幕中居中,(3)应根据(4)放置-在它的“右上角”中,从你的图像看,似乎4的右上角正好在3的中心。你不想要这个吗?是的,你也可以这样说:)这是不可能的?!我不明白你的答案。如果您确实希望3的中心位于4的右上角,那么不,您不能在布局中这样做,您需要在运行时测量并定位3。如果它不需要在中间,那么可以在xml布局中使用任意的空间值来完成。但是,如果3具有动态维度,则可能会导致一些问题。