android - view centered above in between weight distributed views in linear layout -


i trying achieve layout follows:

floating button above

two views weight 2(green view) & 1(blue view) in linear layout. , floating button centered in between views infront of them. not possible using linear layout. can give little here

update: here have done

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <view         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="2"         android:background="#22b14c" />      <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:text="to floating button" />      <view         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1"         android:background="#00a2e8" /> </linearlayout> 

and got is

floating button between

thanks coordinatorlayout in design support library problem can solved.

<android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical">          <view             android:id="@+id/top"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="2"             android:background="#22b14c" />          <view             android:id="@+id/bottom"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="1"             android:background="#00a2e8" />     </linearlayout>      <android.support.design.widget.floatingactionbutton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_margin="@dimen/fab_margin"         app:backgroundtint="#a349a4"         app:fabsize="normal"         app:layout_anchor="@id/top"         app:layout_anchorgravity="bottom|right|end" />  </android.support.design.widget.coordinatorlayout> 

you have anchor floatingactionbutton top view using layout_anchor attribute , set anchor gravity using layout_anchorgravity

and here get:

solution image


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -