带有线性布局和垂直方向的Android布局不起作用
我有两个片段,它们托管在具有以下布局的活动上带有线性布局和垂直方向的Android布局不起作用,android,xml,android-fragments,android-linearlayout,Android,Xml,Android Fragments,Android Linearlayout,我有两个片段,它们托管在具有以下布局的活动上 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="20dp" > <
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frameContainer1"
android:orientation="horizontal"
></LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frameContainer"
android:orientation="vertical"
></LinearLayout>
</LinearLayout>
</FrameLayout>
另一个容器是这样的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/frameContainer"
>
<ImageView
android:layout_width="400dp"
android:layout_height="40dp"
android:id="@+id/image1"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/image1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/name1"/>
</RelativeLayout>
问题是外观完全过时了。frameContainer1
显示在操作栏的顶部。我想要的是frameContainer1垂直显示在另一个容器之前
我怎样才能修好它
更新屏幕截图中的小图像是frameContainer1内容
希望这有帮助。 请从.xml文件中删除您的
FrameLayout
去掉这个,
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
</FrameLayout>
因为它是其他布局的父级
另一件事是您在Linearlayout中包含了
Framelayout,因此它不会正常生效。您可以添加屏幕截图吗?Linearlayout:frameContainer1
和image1
之间的关系在哪里???可以显示完整的xml吗file@DanhDC一个用户格式化了我的问题。这更有意义吗?@Alex运行此布局时,您能否显示屏幕截图,使用相对布局或线性布局作为根布局将很容易理解您的问题。我的意思是删除框架布局,只保留第二层的线性布局。删除框架布局。好啊但替换为什么?Linearlayout应该是父级@亚历克斯