2014-11-28 2 views
0

Я попытался следующие:Место кнопки рядом с 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="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. Как я могу это достичь?

+0

set layout_height of FrameLayout для wrap_content – Suvitruf

ответ

2

попробовать, как это,

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

добавить в frameLayout и кнопки:

android:layout_weight = "2" 
1

просто добавить вес в 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" > 
1

Попробуйте

<?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> 
Смежные вопросы