0
我有這樣一個佈局:覆蓋線性浮動按鈕佈局
但正如你所看到的,浮動按鈕沒有覆蓋在編輯文本。有沒有辦法在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>
這裏是我希望它看起來 -
有一個原因,所有其他答案使用FrameLayout或Relativ eLayout。 LinearLayout被命名爲Linear。它不支持圖層。請在您閱讀的其他答案中使用FrameLayout或RelativeLayout。 –
使用框架佈局來實現這一點 –
你不能這樣做,你只需要使用linearlayout,你必須使用framelayout的 – Pankaj