I am trying to implement a screen which looks similar to this one:
I am able to implement the above. I have used the following logic :
FrameLayout
|- Linear Layout
|- Button (Purple Colour, Layout Width = 1)
|- Button (Blue Colour, Layout Width = 1)
|- Linear Layout (Layout_Gravity = center)
|- Button (Button Text)
Source Code
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:background="@color/accent_material_light"
android:orientation="vertical"
android:padding="0dp"
android:weightSum="100">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="40"
android:background="@android:color/holo_purple" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="60"
android:background="@android:color/holo_blue_light" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@color/abc_search_url_text_pressed">
<Button
android:id="@+id/button2"
android:layout_height="48dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent" />
</LinearLayout>
</FrameLayout>
Question :-
How should I place the Button on the border of two views if the two views (purple and blue views) have to take 40% and 60% of the screen respectively. I cannot use layout_gravity to center in that case. How to solve this problem ?
It looks something like this :-
How to fix this problem ?