2

I created bellow Layout :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeStart"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back"
    tools:context=".SongsActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/header"
        android:orientation="vertical">

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

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:src="@drawable/felesh_m" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center_horizontal|center_vertical"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <ImageButton
                    android:id="@+id/imbCenter"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:background="@null"
                    android:src="@drawable/hosein_hlarge" />
            </LinearLayout>

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:src="@drawable/felesh_m" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4" />
    </LinearLayout>
</RelativeLayout>

See bellow Image :

enter image description here

1 Answers1

4

Change your layout like this. You don't need to take multiple Linear Layouts. That is bad for performance. So I have changed it to single Linear Layout with some Weight properties.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeStart"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/common_ic_googleplayservices">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/common_ic_googleplayservices"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="3"
            android:orientation="horizontal">

            <ImageButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.50"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />


            <ImageButton
                android:id="@+id/imbCenter"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />

            <ImageButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.50"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4" />
    </LinearLayout>
</RelativeLayout>

enter image description here

greybeard
  • 2,249
  • 8
  • 30
  • 66
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
  • @ jaydroider.Thnaks a lot. –  Sep 08 '16 at 08:22
  • 1
    The RelativeLayout or the first LinearLayout are not necessary. I'd remove both the LinearLayouts, since all can be done by using a single RelativeLayout. Giving your UI a faster responsiveness – Phantômaxx Sep 08 '16 at 08:22
  • 1
    @Rotwang Sir he has taken `Recycler View` in vertical orientation and then he want some more 3 images in horizontal so that's why may be he has setup like that. – Jay Rathod Sep 08 '16 at 08:24
  • 1
    @JoJoRoid Accept and upvote the answer if it's helped you. – Jay Rathod Sep 08 '16 at 08:24
  • 1
    Again: all can be done by using a single RelativeLayout. If you know how to use it. – Phantômaxx Sep 08 '16 at 08:26
  • 1
    while using weight in horizontal LinearLayout, the width of inner objects should be 0dp – Matcoil Sep 08 '16 at 08:26
  • 2
    @Rotwang You are right sir it can be done using single `Relative Layout`.But as of now i have just making sense to OP sir. – Jay Rathod Sep 08 '16 at 08:31