Android 将按钮放置在framelayout旁边

Android 将按钮放置在framelayout旁边,android,Android,我尝试了以下方法: <?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" > <Frame

我尝试了以下方法:

<?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" >

<FrameLayout
    android:id="@+id/recipe_fragment_camera_preview"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/recipe_fragment_imageview_pattern"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/imageview_description" />

</FrameLayout>

<Button
    android:id="@+id/recipe_fragment_button_take_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_take_photo" />

不幸的是,这不起作用。FrameLayout正在隐藏按钮,因为FrameLayout占据了整个屏幕。我想在FrameLayout旁边有一个按钮。我怎样才能做到这一点呢?

试着这样做

<?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" >

<FrameLayout
    android:id="@+id/recipe_fragment_camera_preview"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/recipe_fragment_imageview_pattern"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/imageview_description" />

</FrameLayout>

<Button
    android:id="@+id/recipe_fragment_button_take_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_take_photo" />

像这样试试

<?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" >

<FrameLayout
    android:id="@+id/recipe_fragment_camera_preview"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/recipe_fragment_imageview_pattern"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/imageview_description" />

</FrameLayout>

<Button
    android:id="@+id/recipe_fragment_button_take_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_take_photo" />

加载项框架布局和加载项按钮:

android:layout_weight = "2"

加载项框架布局和加载项按钮:

android:layout_weight = "2"

只需在FrameLayout中添加权重

<FrameLayout android:layout_weight="1"
android:id="@+id/recipe_fragment_camera_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" >

只需在FrameLayout中添加权重即可

<FrameLayout android:layout_weight="1"
android:id="@+id/recipe_fragment_camera_preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal" >

试试这个

 <?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">

   <FrameLayout
     android:id="@+id/recipe_fragment_camera_preview"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_above="@recipe_fragment_button_take_photo"
     android:orientation="horizontal" >

    <ImageView
      android:id="@+id/recipe_fragment_imageview_pattern"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:contentDescription="@string/imageview_description" />

  </FrameLayout>

  <Button
    android:id="@+id/recipe_fragment_button_take_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="@string/button_take_photo" />

</RelativeLayout>

试试这个

 <?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">

   <FrameLayout
     android:id="@+id/recipe_fragment_camera_preview"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_above="@recipe_fragment_button_take_photo"
     android:orientation="horizontal" >

    <ImageView
      android:id="@+id/recipe_fragment_imageview_pattern"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:contentDescription="@string/imageview_description" />

  </FrameLayout>

  <Button
    android:id="@+id/recipe_fragment_button_take_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="@string/button_take_photo" />

</RelativeLayout>


set layout\u FrameLayout的高度要换行\u内容set layout\u FrameLayout的高度要换行\u内容