2015-04-20 2 views
0

У меня есть макет, как это:Overlay Плавающих кнопок в Linear Layout

enter image description here

Но, как вы можете видеть, Плавающая кнопка не накладывая редактирования текста. Есть ли способ сделать это в LinearLayout? (Я не могу использовать другие макеты).

Я видел много ответов на SO, но все они используют либо RelativeLayout, либо FrameLayout.

Вот мой XML (кнопка плавающей в конце) -

<LinearLayout 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:weightSum="10" 
    android:orientation="vertical" 
    tools:context=".Start"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:text="New Button" 
      android:id="@+id/button" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:text="New Button" 
      android:id="@+id/button2" /> 

    </LinearLayout> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="4" 
     android:layout_gravity="center_horizontal" 
     android:id="@+id/editText" /> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="4" 
     android:layout_gravity="center_horizontal" 
     android:id="@+id/editText2" /> 

    <!--Overlay this image --> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:src="@drawable/ic_mic" 
     android:layout_gravity="right" /> 

</LinearLayout> 

Вот как я хочу, чтобы это выглядело -

enter image description here

+0

есть причина, по которой все остальные ответы используют FrameLayout или Relativ eLayout. LinearLayout имеет имя Linear. Он не поддерживает слои. Используйте FrameLayout или RelativeLayout, как в одном из других ответов, которые вы читаете. –

+0

использовать фрейм макет для достижения этого –

+0

Вы не можете сделать то, что вы хотите, используя только linearlayout, вы должны использовать framelayout для этого – Pankaj

ответ

0

Используйте FrameLayout как код ниже:

<FrameLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

<ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView" 
     android:src="@drawable/ic_mic"/> 
</FrameLayout> 
Смежные вопросы