0
我的布局工作正常,它内部有一个父项Linear Layout
和多个Linear Layouts
。框架布局内部的线性布局停止工作
现在我需要添加一个背景图像,所以我需要在这里添加一个框架布局。
当我将父母Linear Layout
更改为Frame Layout
时,它将消失linear layout
中的所有项目。
如果我加Frame Layout
,在Linear Layout
里面,它会消失线性布局中的所有项目。
我无法理解如何在不移除线性布局项目的情况下放置框架布局。
布局代码很长。
我把以上的一部分。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/image11"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="10dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="7:00 PM CST"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/white"
android:fontFamily="sans-serif-medium"
android:textSize="12sp"
/>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/icon2"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical"
android:background="@drawable/cart_custom_background"
android:paddingBottom="2dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="horizontal"
android:layout_marginRight="1dp"
android:layout_marginLeft="1dp"
>
尝试相对布局,而不是框架布局 – Dnyanesh
谢谢@Dnyanesh,当我将'父布局'改为'相对布局'时,所有元素消失 – Kirmani88
您确定您的layout_height/layout_width不等于帧布局中的0 dp ? –