Android 线性布局内部框架布局
我在androidstudio中有以下代码,其中在一个框架布局中有两个线性布局。但是,这两个布局图中的按钮彼此重叠。是否可以将两个线性布局(包括按钮)垂直放置在彼此相邻的位置,而不是映射到彼此的顶部Android 线性布局内部框架布局,android,android-layout,android-framelayout,Android,Android Layout,Android Framelayout,我在androidstudio中有以下代码,其中在一个框架布局中有两个线性布局。但是,这两个布局图中的按钮彼此重叠。是否可以将两个线性布局(包括按钮)垂直放置在彼此相邻的位置,而不是映射到彼此的顶部 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF"
tools:context="com.dji.GSDemo.GoogleMap.MainActivity">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<FrameLayout
android:id="@+id/fram_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/locate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Locate"
android:layout_weight="1"/>
<Button
android:id="@+id/add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"
android:layout_weight="1"/>
<Button
android:id="@+id/clear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Clear"
android:layout_weight="1"/>
<Button
android:id="@+id/btn_draw_State"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Free Draw" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/config"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Config"
android:layout_weight="0.9"/>
<Button
android:id="@+id/upload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Upload"
android:layout_weight="0.9"/>
<Button
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start"
android:layout_weight="1"/>
<Button
android:id="@+id/stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Stop"
android:layout_weight="1"/>
</LinearLayout>
</FrameLayout>
下面是按钮显示方式的屏幕截图
FrameLayout
将在屏幕上的同一帧中布局所有子项
如果希望多个子元素垂直或水平堆叠,可以将它们包装在
线性布局中。在这种情况下,您只需将根FrameLayout
替换为LinearLayout
,并使用android:orientation=“vertical”
将两个LinearLayout
垂直堆叠。FrameLayout
将在屏幕上的同一帧中布局所有子项
如果希望多个子元素垂直或水平堆叠,可以将它们包装在线性布局中。在这种情况下,您只需将根FrameLayout
替换为LinearLayout
,并使用android:orientation=“vertical”
将这两个LinearLayout
垂直堆叠。尝试将xml代码根中的FrameLayout
更改为LinearLayout
并设置android:orientation=“vertical”
尝试将xml代码根目录中的FrameLayout
更改为LinearLayout
并设置android:orientation=“vertical”
您可以添加一个屏幕截图来显示它的外观吗?您尝试过相对布局吗?为什么不尝试使用LinearLayout或RelativeLayout而不是FrameLayout?您可以添加一个屏幕截图来显示它的外观吗?您是否尝试过相对布局?为什么不尝试使用LinearLayout或RelativeLayout而不是FrameLayout?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fram_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/locate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Locate" />
<Button
android:id="@+id/add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Add" />
<Button
android:id="@+id/clear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Clear" />
<Button
android:id="@+id/btn_draw_State"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Free Draw" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/config"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:text="Config" />
<Button
android:id="@+id/upload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:text="Upload" />
<Button
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Start" />
<Button
android:id="@+id/stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Stop" />
</LinearLayout>
</LinearLayout>