I'm using a few LinearLayouts and am having trouble getting the items to be centered.
Here's my code block:
<LinearLayout
android:id="#+id/title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/avatar"
android:visibility="gone"
android:layout_gravity="center_vertical"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/title"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#drawable/touch_clear_bg" />
<TextView
android:id="#+id/subtitle"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
So I want the ImageView and the nested LinearLayout to be vertically centered in the title_container, which is a horizontal LinearLayout.
Is there a reason why my approach isn't working?
You have to set the
android:gravity="center_vertical"
only in the parent LinearLayout(title_container).
And you can see the code here:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/title_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageView
android:id="#+id/avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/touch_clear_bg" />
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
change
android:layout_gravity="center_vertical"
to
android:layout_gravity="center"
Type
<LinearLayout
android:id="#+id/title_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center">
This will put whole layout in center
Related
I have a problem with my alignment in the ActionBar.
It is centering the Imageview between the icons, but what I want is that it is centering not depend on the buttons but on the whole ActionBar. How can I achieve this?
<?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="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/action_bar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#fff"
android:textSize="24sp" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:layout_marginBottom="20dp"
android:src="#drawable/triptracker_logo"/>
</LinearLayout>
In my java class:
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.actionbar_layout);
What I got from your question is that you want the action bar title to be in center independent of the icon.
Use RelativeLayout instead of LinearLayout
I hope it will work
<?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="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/action_bar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#fff"
android:textSize="24sp" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:layout_marginBottom="20dp"
android:src="#drawable/triptracker_logo"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"/>
</RelativeLayout>
Try this...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#b19d9d"
android:orientation="horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/ic_male" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|end"
android:gravity="right|end"
android:orientation="horizontal">
<TextView
android:id="#+id/action_bar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="right|center_vertical"
android:text="HELLO WORLD"
android:textColor="#fff"
android:textSize="24sp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
Use RelativeLayout as root layout instead of LinearLayout
android:layout_centerInParent="true" for TextView
android:layout_alignParentEnd="true" for ImageView to set it at the end
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:text="Helo"
android:layout_centerInParent="true"
android:id="#+id/action_bar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#fff"
android:textSize="24sp" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:layout_marginBottom="20dp"
android:src="#drawable/star"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout >
I've one ImageView and 3 TextViews. I need to align the 3 text views below the imageview. the first on the left . the second in center. the 3rd on the right.
below code is working for normal and small screens. but for tablets and large screens, the first text view is not below the imageview. it's shifted too left. and the third TextView is shifted too Right.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Rel_wind2_img">
<ImageView
android:id="#+id/window2_image1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="#+id/window2_image1"/>
<TextView
android:id="#+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/window2_image1"
android:layout_alignParentLeft="true"
android:textAlignment="center"/>
<TextView
android:id="#+id/TV2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/window2_image1"
android:layout_centerInParent="true"
android:textAlignment="center"/>
<TextView
android:id="#+id/TV3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/window2_image1"
android:layout_alignParentRight="true"
android:text="#string/info2_txt_moves"
android:textAlignment="center"/>
</RelativeLayout>
I can solve this problem grammatically. but i need a simple way using XML.
Give layout weight inside a linear layout. It will set the width equally between all textviews. try this
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Rel_wind2_img"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="#+id/window2_image1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/window2_image1"
>
<TextView
android:id="#+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:textAlignment="center"/>
<TextView
android:id="#+id/TV2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:textAlignment="center"/>
<TextView
android:id="#+id/TV3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="info2_txt_moves"
android:layout_weight="1"
android:textAlignment="center"/>
</LinearLayout>
</RelativeLayout>
Best way to do this kind of UI design just divide the Layout into weights.
because if we divide the ui in weights it will automatically adjust according to divide size so there will be no problem on any device.
like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Rel_wind2_img">
<LinearLayout
android:id="#+id/tr"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/window2_image1"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="#color/black"
/>
</LinearLayout>
<LinearLayout
android:layout_below="#+id/tr"
android:weightSum="3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dhshshs"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/TV2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fjkhajhjfha"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/TV3"
android:text="aoifoijoajoifjoajofjafafg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/window2_image1"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Use this One :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/Rel_wind2_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/window2_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#mipmap/ic_launcher" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="dfgf"
android:id="#+id/TV1"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAlignment="center" />
<TextView
android:id="#+id/TV2"
android:text="dfgf"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
<TextView
android:id="#+id/TV3"
android:text="dfgf"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
Hope this help you...if you need any help you can ask
I have to create a horizontally aligned textview and an imageview that is placed below of another image view. The problem is they are not getting horizontally aligned. What should i be doing to avoid this problem?..
Whats happening right now:
It should be like this:
My Code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
>
<ImageButton
android:id="#+id/imgBtnItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:background="#android:color/transparent">
</ImageButton>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="9sp"
android:layout_below="#+id/imgBtnItem">
</TextView>
<ImageButton
android:id="#+id/imgBtnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imgBtnItem"
android:layout_toRightOf="#+id/txtName"
android:background="#android:color/transparent"
>
</ImageButton>
</RelativeLayout>
Use as (edit dimens according to use):
<?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"
android:gravity="center"
android:padding="5dp"
>
<ImageButton
android:id="#+id/imgBtnItem"
android:layout_width="150dp"
android:layout_height="150dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:background="#color/colorAccent">
</ImageButton>
<TextView
android:id="#+id/txtName"
android:layout_width="50dp"
android:layout_height="50dp"
android:textStyle="bold"
android:textSize="9sp"
android:layout_marginTop="4dp"
android:layout_below="#+id/imgBtnItem"
android:background="#color/colorPrimary">
</TextView>
<ImageButton
android:id="#+id/imgBtnAdd"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/colorPrimaryDark"
android:layout_below="#+id/imgBtnItem"
android:layout_alignTop="#id/txtName"
android:layout_toEndOf="#id/txtName"
android:layout_alignEnd="#+id/imgBtnItem">
</ImageButton>
</RelativeLayout>
Output:
Use this Tested code. dont use Relative layout for simple layout. It's not good practise
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp">
<ImageButton
android:id="#+id/imgBtnItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#android:color/transparent"
android:scaleType="fitCenter"
android:src="#drawable/amojee_logo"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="9sp"
android:text="hi how are you"
android:textStyle="bold"/>
<ImageButton
android:id="#+id/imgBtnAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/amojee_logo"
android:background="#android:color/transparent" />
</LinearLayout>
</LinearLayout>
You may try out the following XML code. I have run this and it's doing ok. I have added some icons and text for testing you may change according to your need.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/imgBtnItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher">
</ImageButton>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:id="#+id/txtName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="9sp"
android:layout_below="#+id/imgBtnItem"
android:text="Hello"
android:layout_weight="0.7">
</TextView>
<ImageButton
android:id="#+id/imgBtnAdd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/imgBtnItem"
android:layout_toRightOf="#+id/txtName"
android:background="#android:color/transparent"
android:src="#drawable/abc_btn_check_to_on_mtrl_015"
android:layout_weight="0.3">
</ImageButton>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I want to display text field Duration below the text field Item.I am having the list view which is populated in different for even and odd rows. But the thing is I want the two text field in parallel to image I want to display vertically, but when I put the two text field in the Liner Vertical layout it shows error. How to display the two text field in vertical manner. Sorry if any mistake in my english. Thanks in advance.
Below is my code:
<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:orientation="horizontal" >
<ImageView
android:id="#+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="#string/app_name"
android:src="#drawable/male" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="#string/app_name"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
Try this!!!
It will give the view, what you are looking till.
Please check below my code here i manage your both different item view in single layout so you have just show/hide respective layout based on item :
<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:orientation="vertical"
android:gravity="center">
<LinearLayout
android:id="#+id/male_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/gender_image_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:src="#drawable/male" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/name_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/female_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/gender_image_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:src="#drawable/female" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/name_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Note : android:layout_weight is used take rest of area.
use this ->
<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:orientation="horizontal" >
<ImageView
android:id="#+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="#string/app_name"
android:src="#drawable/male" />
<LinearLayout
android:layout_weight="60.5"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:id="#+id/name"
android:text="asdasdas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1"
android:text="asdasd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
</LinearLayout>
<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:orientation="horizontal" >
<ImageView
android:id="#+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="#string/app_name"
android:src="#drawable/male" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_dark" />
<TextView
android:id="#+id/name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
</LinearLayout>
PS: put the weights and width accordingly... :)
I am trying to combine TextView and ImageView and want to place the TextViews at the center of both the circles in the image but somehow I haven't been able to figure out a solution that will work across different kind of devices.
This is the image I'm trying to use:
This is what I've tried till now. I've put both the imageview and the textview in a framelayout and then tried to adjust the textview by using linearlayouts and layout weights.
`
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80">
<ImageView
android:id="#+id/home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/circle_pic"
android:adjustViewBounds="true" />
<LinearLayout
android:id="#+id/home_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="60"
android:gravity="center">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="85"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="#color/white"
android:text="#string/text1"/>
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:textColor="#color/white"
android:text="#string/text2"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/text3"
android:orientation="horizontal"
android:layout_weight="40"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="#+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="#string/tv3"
android:textColor="#color/white"/>
<TextView
android:id="#+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:text="000"
android:textColor="#color/white"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>`
You can use RelativeLayout to achieve this as
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="<your_drawable>"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/imageView"
android:layout_alignRight="#id/imageView"
android:layout_alignTop="#id/imageView"
android:layout_alignBottom="#id/imageView"
android:gravity="center"/>
</RelativeLayout>