Linear layout inside relative layout is not seen in horizontal view - android

I have 4 linear layout inside the relative layout and a button. I am able to see only first 3 relative layout and button in horizontal view. The fourth linearlayout is not seen but it is seen in the vertical view. Please help.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal"
android:id="#+id/linearLayout1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="top">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gen"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/gen"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:layout_below="#+id/linearLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView2"
android:src="#drawable/year"/>
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:layout_below="#+id/linearLayout2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:src="#drawable/im"/>
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout4"
android:layout_below="#+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="53dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView4"
android:src="#drawable/rt2"/>
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="58dp"
android:id="#+id/filterbutton"
android:text="filter"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:textStyle="bold"/>
</RelativeLayout>

You need to keep entire child linear layout inside scrollview so that it will be scrollable & visible.Check below updated xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/filterbutton"
android:layout_alignParentTop="true"
android:fadingEdge="none"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gen" />
<TextView
android:id="#+id/gen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/year" />
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/im" />
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/rt2" />
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/filterbutton"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:text="filter"
android:textStyle="bold" />
</RelativeLayout>

Add an ScrollingView as the parent,and inside that the RelativeLayuot and it add an scrollbar to see all.
You can see more info in android developers ScrollingView

Try out this solution,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:fadingEdge="none"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<LinearLayout
android:id="#+id/linearLayoutWhole"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/gen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/filterbutton"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:text="filter"
android:textStyle="bold" />
</RelativeLayout>

Related

Making tab content scrollable

I have a simple structure inside my layout, with a RelativeLayout for my header and right bellow that, I have a TabHost with 3 different tabs. I'm just asking about the content of my first tab here. Right after the tabs and their labels, there are two LinearLayouts followed by a ListView which gets populated via adapter.
Problem is, after those two LinearLayouts, there's very little space for the ListView to be seen, so I'd like to make this entire tab content scrollable.
I tried putting the complete layout surrounded by ScrollView, that didn't work. Then I tried putting the ScrollView around different tags, but no matter where I put it, I couldn't get the desired effect. Is there any other approach to this, cause ScrollView doesn't seem to be a solution right now.
Here's the XML file:
<?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/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/rlTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cardview_dark_background">
<TextView
android:id="#+id/tvPlayerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#9 Zlatan Ibrahimovic"
android:textColor="#FFF"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/player_details_playerLogo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/tvPlayerName"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:src="#drawable/ic_launcher"/>
</RelativeLayout>
<TabHost
android:id="#+id/tabHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#id/rlTop">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cardview_dark_background"></TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:id="#+id/playerInfoContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:background="#EEE"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="#+id/tvPlayerDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:padding="10dp"
android:text="Oyuncu Bilgisi"
android:textSize="16dp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/playerInfoFirstRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/playerInfoContainer">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/team_details_teamLogo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="25dp"
android:src="#drawable/se"/>
<LinearLayout
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayerNationalTeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Isvec"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvNationalTeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Milli Takim"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayerAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="35"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Yas"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="50dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayerHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="1.84 cm"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Boy"
android:textSize="10dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/playerInfoSecondRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/playerInfoFirstRow"
android:layout_marginTop="25dp">
<LinearLayout
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvFoot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Sag"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvPreferredFoot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Tercih Ettigi Ayak"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayerPosition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Hucum"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvPosition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Posizyon"
android:textSize="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayerWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="81 kg"
android:textSize="18dp"/>
<TextView
android:id="#+id/tvWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Kilo"
android:textSize="10dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llRoles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/playerInfoSecondRow"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#EEE"
android:orientation="horizontal">
<TextView
android:id="#+id/tvPlayerTeams"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:padding="10dp"
android:text="Oynadigi Takimlar"
android:textSize="16dp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/llRolesLegend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/llRoles">
<TextView
android:id="#+id/tvYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="Yil"
android:textSize="14dp"/>
<TextView
android:id="#+id/tvTeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:text="Takim"
android:textSize="14dp"/>
<TextView
android:id="#+id/tvContract"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="144dp"
android:text="Kontrat"
android:textSize="14dp"/>
</LinearLayout>
<ListView
android:id="#+id/lvPlayerRoles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/llRolesLegend"
android:layout_marginTop="16dp"/>-->
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/llPlayerCareerStatisticsTotals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:background="#EEE"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="#+id/tvPlayerCareerStatisticsTotals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:padding="10dp"
android:text="Kariyer Istatistikleri"
android:textSize="16dp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/llPlayerCareerStatisticsTotals"
android:orientation="horizontal">
<TextView
android:id="#+id/tvMatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:layout_marginLeft="50dp"
android:layout_marginTop="5dp"
android:layout_toEndOf="#+id/linearLayout"
android:layout_toRightOf="#+id/linearLayout"
android:text="Mac"/>
<ImageView
android:id="#+id/ivGoals"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/tvMatches"
app:srcCompat="#drawable/ic_launcher"/>
<ImageView
android:id="#+id/ivAssists"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/ivGoals"
app:srcCompat="#drawable/ic_launcher"/>
<ImageView
android:id="#+id/ivYellowCards"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/ivAssists"
app:srcCompat="#drawable/ic_launcher"/>
<ImageView
android:id="#+id/ivRedCards"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/ivYellowCards"
app:srcCompat="#drawable/ic_launcher"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:orientation="horizontal">
<TextView
android:id="#+id/tvTotalMatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:layout_marginLeft="50dp"
android:layout_marginTop="5dp"
android:layout_toEndOf="#+id/linearLayout"
android:layout_toRightOf="#+id/linearLayout"
android:text="458"/>
<TextView
android:id="#+id/tvTotalGoals"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="35dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/tvMatches"
android:text="345"/>
<TextView
android:id="#+id/tvTotalAssists"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="32dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivGoals"
android:text="112"/>
<TextView
android:id="#+id/tvTotalYellowCards"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="32dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivAssists"
android:text="76"
app:srcCompat="#drawable/ic_launcher"/>
<TextView
android:id="#+id/tvTotalRedCards"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/playerInfoContainer"
android:layout_marginLeft="32dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivYellowCards"
android:text="21"
app:srcCompat="#drawable/ic_launcher"/>
</LinearLayout>
<ListView
android:id="#+id/listViewPlayerSeasons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout2"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>

Scroll view is not scrolling smoothly when tab layout and viewpager is placed inside scroll view?

I am facing the issue in scroll view is not scrolling smoothly when the tab navigation is placed inside the scroll view .
The below code is the xml file in which the tab navigation is placed inside the scroll view. I don't know the reason why this issue is occurring.Please help me how to solve this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_interview_scam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.zcodia.scamlookup.Activities.ScamDetailsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:foregroundGravity="center"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:id="#+id/profile_image"
android:background="#mipmap/bg_splash_cut"
android:src="#drawable/icon1"
/>
<TextView
android:text=""
android:textSize="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:id="#+id/subCategoryTitle"
android:layout_above="#+id/textView11"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:textColor="#000000"/>
<TextView
android:text="Item ID:"
android:textSize="15dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView11"
android:layout_alignBottom="#+id/profile_image"
android:layout_marginLeft="15dp"
android:layout_marginBottom="13dp" />
<TextView
android:text=""
android:textSize="15dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scamId"
android:layout_alignBottom="#+id/profile_image"
android:layout_marginLeft="75dp"
android:layout_marginBottom="13dp" />
<TextView
android:text="#string/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="19dp"
android:layout_marginLeft="10dp"
android:id="#+id/arrow_id"
android:textColor="#FFFFFF"
android:textSize="20dp"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FAFAFA"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout4"
android:layout_below="#+id/profile_image"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relative_layout_1"
android:background="#FFFFFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="No Of Cases Reported"
android:layout_marginLeft="15dp"
android:textSize="14dp"
android:id="#+id/report_cases_id"
android:gravity="center"/>
<TextView
android:textSize="14dp"
android:textColor="#EF5350"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scam_report_count"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="12dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FAFAFA">
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Report Loss"
android:textSize="14dp"
android:paddingLeft="15dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:id="#+id/report_loss_id"
android:gravity="center"
/>
<TextView
android:textSize="14dp"
android:textColor="#EF5350"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/loos_id"
android:layout_marginRight="10dp"
android:paddingTop="12dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Possible Scammer Location"
android:textSize="14dp"
android:paddingLeft="15dp"
android:gravity="center"
android:id="#+id/possible_scammer_location_id" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:textColor="#EF5350"
android:paddingTop="12dp"
android:layout_marginRight="10dp"
android:id="#+id/scam_location"
android:ellipsize="end"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#FAFAFA"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="40dp"
android:text="Target Medium"
android:textSize="14dp"
android:paddingTop="10dp"
android:layout_weight="1"
android:layout_marginLeft="10dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginRight="0dp"
android:id="#+id/scam_medium_linear">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scam_medium_icon"
android:textSize="20dp"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:textColor="#EF5350"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/scam_medium_text"
android:textColor="#EF5350"
android:layout_marginTop="10dp"
android:layout_marginLeft="0dp"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:gravity="center"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Tactic"
android:layout_marginLeft="15dp"
android:textSize="14dp"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tactic_linear_layout"
android:background="#drawable/margin_color"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginTop="0dp"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/add_new_tactics"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangele_width"
>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tab_layout"
app:tabMode="fixed"
app:tabTextColor="#ccc"
app:tabPaddingStart="12dp"
app:tabSelectedTextColor="#D32F2F"
app:tabIndicatorColor="#D32F2F"
app:tabGravity="fill"
></android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="420dp"
android:id="#+id/viewPager2"
android:background="#FAFAFA">
</android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
</LinearLayout>
Replace android.support.v4.widget.NestedScrollView instead of scroll view. It works for me try this....

Unable to set header in Linear layout in android

<?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:background="#00b9e8"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView2"
android:layout_marginRight="32dp"
android:src="#drawable/backbutton" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#6AED83"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="122dp"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginLeft="14dp"
android:layout_marginTop="16dp"
android:background="#drawable/roundedlinearlayout3"
android:weightSum="4" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/user_s_icon" />
<EditText
android:id="#+id/editText1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4" >
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/layout1"
android:layout_below="#+id/layout1"
android:layout_marginTop="27dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</RelativeLayout>
This is my Xml i am Unable to set Linear layout inside text view and image button Like desire image:
This is my desire screen : below is my current screen :
i am unable to set text-view and image view on top of Linear layout
Try this way,hope this will help you to solve your problem.
Instead of using RelativeLayout use LinearLayout which can be easily done your requirement.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00b9e8"
android:orientation="vertical">
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/backbutton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="10dp"
android:background="#drawable/roundedlinearlayout3">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4"
android:drawableLeft="#drawable/user_s_icon">
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</LinearLayout>
<LinearLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#6AED83"
android:gravity="center"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>

Android layout Fix

I want an android Top menu section like the below image
But Now I am getting the layout like this
This is My Code used in main xml file.
<RelativeLayout 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"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/back_gradient"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/menu"
android:background="#drawable/back_gradient" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:background="#drawable/back_gradient"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp"
android:gravity="center_vertical" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:src="#drawable/search" />
</LinearLayout>
</RelativeLayout>
Can anyone tell me how can i achieve it?
Thanks in advance
try this Layout.
<RelativeLayout 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"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/back_gradient"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/menu"
android:layout_weight="1"
android:background="#drawable/back_gradient" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:background="#drawable/back_gradient"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp"
android:layout_weight="1"
android:gravity="center_vertical" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_weight="1"
android:src="#drawable/search" />
</LinearLayout>
Try this..
Correction in TextView
<RelativeLayout 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"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/back_gradient"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/menu"
android:background="#drawable/back_gradient" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp" //here
android:layout_weight="1" //here
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/back_gradient"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:src="#drawable/search" />
</LinearLayout>
</RelativeLayout>
Use android:gravity="center_horizontal" and android:layout_weight="1" for your TextView.
Try following data
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:background="#123456"
android:text="Welcome"
android:layout_weight="1"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp"
android:gravity="center_horizontal" />
Try this:
<RelativeLayout 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:background="#drawable/back_gradient"
tools:context=".MainActivity" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#drawable/back_gradient"
android:src="#drawable/menu" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/imageView1"
android:layout_toRightOf="#+id/imageButton1"
android:background="#drawable/back_gradient"
android:gravity="center_vertical"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="20dp"
android:src="#drawable/search" />
</RelativeLayout>
Modify your TextView by setting 0dip to android:layout_width and set android:layout_weight="1". So, the updated TextView XML be as follows...
<TextView
android:id="#+id/textView1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="fill_vertical"
android:background="#drawable/back_gradient"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="19sp"
android:gravity="center_vertical" />
Use this layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/back_gradient"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/menu"
android:background="#drawable/back_gradient" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#drawable/back_gradient"
android:text="Welcome"
android:textAlignment="center"
android:textColor="#ffffff"
android:layout_weight="1"
android:textSize="19sp"
android:gravity="center" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:src="#drawable/search" />
</LinearLayout>
Note: Do not include relative layout in this xml.

Button set to wrap content occupies more space than it needs

I am making a layout for my application and I encounter the following problem.
In my layout file
But when I put it in my Fragment (via a ListView, or just with , it looks like this:
category.xml (template to populate ListView afterwards)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/second_grey">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:id="#+id/categoryName"
android:text="#string/sport"
android:textSize="24sp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="12dp"
android:id="#+id/button"
android:text="#string/see_more"
android:textSize="12sp"
android:background="#drawable/blue"
android:textColor="#android:color/white" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="0.99">
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img1"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/football"
android:padding="8dp"
android:id="#+id/tv1"
android:layout_below="#+id/imgContainer1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer2">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img2"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/basketball"
android:padding="8dp"
android:id="#+id/tv2"
android:layout_below="#+id/imgContainer2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img3"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tennis"
android:padding="8dp"
android:id="#+id/tv3"
android:layout_below="#+id/imgContainer3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</LinearLayout>
fragment_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:background="#color/second_grey"
tools:context="com.favega.groups.MainActivity$CategoryFragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/category"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"></include>
Try this.. Use TextView instead of Button if you use Button defaultly it'll take much of size
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="12dp"
android:id="#+id/button"
android:text="see_more"
android:textSize="12sp"
android:background="#drawable/blue"
android:textColor="#android:color/white" />
Remove padding from relative layout of fragment_main.xml

Categories

Resources