Making tab content scrollable - android

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>

Related

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....

Tabs with custom view is not inflating in TabLayout at bottom of screen

I have a layout as following -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical"
android:weightSum="6"
android:id="#+id/main_global_container"
>
<!--<include-->
<!--android:id="#+id/mainAppBar"-->
<!--layout="#layout/view_appbar" />-->
<!--<ProgressBar-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--style="#android:style/Widget.Holo.Light.ProgressBar.Large"-->
<!--android:layout_margin="35dp"-->
<!--android:id="#+id/homescreenProgressbar"-->
<!--android:gravity="center_horizontal"-->
<!--android:visibility="invisible"-->
<!--/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:weightSum="3"
android:layout_weight="2.5"
android:background="#color/black"
android:id="#+id/upper_container">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7"
android:weightSum="2"
android:background="#color/formInactiveFont"
android:id="#+id/upper_left_container"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="Welcome,"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="21dp"
android:id="#+id/textView5"
/>
<TextView
android:text="Devansh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="22dp"
android:layout_marginStart="22dp"
android:layout_marginTop="42dp"
android:id="#+id/textView6"
/>
<TextView
android:text="Custome message will appear here"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="73dp"
android:id="#+id/textView7"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:srcCompat="#drawable/hexagone"
android:id="#+id/imageView"
android:layout_marginRight="12dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="12dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/black"
android:layout_centerHorizontal="true"
android:id="#+id/view4"
android:layout_marginTop="7dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="100"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="27dp"
android:id="#+id/textView8"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
android:background="#drawable/hexagone"/>
<TextView
android:text="Total Score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp"
android:layout_marginTop="13dp"
android:id="#+id/textView11"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="Begainner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView12"
android:layout_centerVertical="true"
android:layout_alignLeft="#+id/textView11"
android:layout_alignStart="#+id/textView11" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.3"
android:background="#color/accentColor"
android:id="#+id/upper_right_container"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Keep Learning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView13"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:srcCompat="#drawable/logo"
android:id="#+id/imageView2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android:text="Take Quiz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/textView13"
android:layout_alignEnd="#+id/textView13"
style="#style/quizBtnHome"
android:id="#+id/button4" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3.5"
android:id="#+id/bottom_container">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/home_view_pager">
</android.support.v4.view.ViewPager>
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="100dp"
app:tabGravity="fill"
app:tabMode="fixed"
/>
</LinearLayout>
i am inflating tabs in tablayout with following xml layout -
<?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:orientation="horizontal"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/star_big_on"
android:id="#+id/imageView3"
/>
<TextView
android:text="Topic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView10"
android:layout_margin="7dp" />
</LinearLayout>
then i am setting up viewpager with my tablayout .
The problem is that i am getting an empty tab layout with empty tabs , they not showing their layout but if i exclude view pager then they are getting inflated properly and show what they are supposed to show .
Please help . Thanks in advance.
Try this it was happening due to LinearLayout weight i have made changes to set TabLayout bottom and LinearLayout Above Tab 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:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_global_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical"
android:weightSum="6"
android:layout_above="#+id/tabLayout">
<!--<include-->
<!--android:id="#+id/mainAppBar"-->
<!--layout="#layout/view_appbar" />-->
<!--<ProgressBar-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--style="#android:style/Widget.Holo.Light.ProgressBar.Large"-->
<!--android:layout_margin="35dp"-->
<!--android:id="#+id/homescreenProgressbar"-->
<!--android:gravity="center_horizontal"-->
<!--android:visibility="invisible"-->
<!--/>-->
<LinearLayout
android:id="#+id/upper_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.5"
android:background="#color/black"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:id="#+id/upper_left_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7"
android:background="#color/formInactiveFont"
android:orientation="vertical"
android:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="21dp"
android:text="Welcome,"
/>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:layout_marginStart="22dp"
android:layout_marginTop="42dp"
android:text="Devansh"
/>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="73dp"
android:text="Custome message will appear here"
/>
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
custom:srcCompat="#drawable/hexagone"/>
</RelativeLayout>
<View
android:id="#+id/view4"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="7dp"
android:background="#color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="27dp"
android:background="#drawable/hexagone"
android:gravity="center"
android:text="100"/>
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="23dp"
android:layout_marginStart="23dp"
android:layout_marginTop="13dp"
android:text="Total Score"/>
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView11"
android:layout_alignStart="#+id/textView11"
android:layout_centerVertical="true"
android:text="Begainner"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/upper_right_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.3"
android:background="#color/accentColor"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="Keep Learning"/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
custom:srcCompat="#drawable/logo"/>
<Button
android:id="#+id/button4"
style="#style/quizBtnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView13"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/textView13"
android:text="Take Quiz"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.5"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="#+id/home_view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="100dp"
app:tabGravity="fill"
app:tabMode="fixed"
/>
</RelativeLayout>
I have solved it , so to anyone who might have this problem in future ,
Remove getPageTitle() method from your PagerAdaptor class and do things in this order -
add fragments to pageradaptor.
setup pageradaptor with you tabslayout
inflate tabs with custom layout

Adjust layout to fit for every content Android

I have some customized shape for one layout background, but some content is mixed up depends on what content i open.
I will show you now three images:
1.
2.
3.
How could i simplify this layout and if you can see, the layout size changes depends on size of text and if there is image in it.
This is how my layout looks:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="#+id/parent_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bg_dialog"
android:fillViewport="false">
<RelativeLayout
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/bg_status"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:orientation="vertical"
android:paddingTop="#dimen/feed_item_padding_top_bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="#dimen/feed_item_padding_left_right"
android:paddingRight="#dimen/feed_item_padding_left_right">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profilePic"
android:layout_width="#dimen/feed_item_profile_pic"
android:layout_height="#dimen/feed_item_profile_pic"
android:src="#drawable/user_profile_image"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/feed_item_profile_info_padd"
android:paddingStart="#dimen/feed_item_profile_info_padd">
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_item_profile_name"
android:textStyle="bold"/>
<TextView
android:id="#+id/timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/timestamp"
android:textSize="#dimen/feed_item_timestamp"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/txtStatusMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/feed_item_status_pad_left_right"
android:paddingRight="#dimen/feed_item_status_pad_left_right"
android:paddingTop="#dimen/feed_item_status_pad_top"
android:textColor="#android:color/black"/>
<ImageView
android:id="#+id/feedImage1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#android:color/white"
android:visibility="visible"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:button="#drawable/like_button_state"
android:padding="10dp"
android:text="#string/btn_like_text"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#android:color/black"
android:textSize="18sp"/>
<Button
android:id="#+id/btn_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:drawableLeft="#drawable/ic_comment"
android:drawableStart="#drawable/ic_comment"
android:padding="10dp"
android:text="#string/btn_comment_text"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#android:color/black"
android:textSize="18sp"/>
<ImageButton
android:id="#+id/btn_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:gravity="center"
android:padding="10dp"
android:src="#drawable/ic_action_share"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<Button
android:id="#+id/btn_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#null"
android:gravity="center"
android:text="REPORT"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btn_report"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/tv_category"
android:layout_toStartOf="#+id/tv_category"
android:gravity="center"
android:text="Category:"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tv_info"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="#Good Night"
android:textColor="#android:color/holo_red_dark"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>

Linear layout inside relative layout is not seen in horizontal view

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>

margin-botton doesnt work in layout android

I need move up the button "Choose a picture" I try with margin-button but doesn't work. Look the picture and the code. Any help? I dont know how solve this problem. Maybe Padding, but I tried and doesn't work too.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="#style/activity_main" android:background="#FFFFFF">
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/RelativeLayout">
<ImageView
android:layout_width="130dp"
android:layout_marginTop="50dp"
android:layout_height="140dp"
android:id="#+id/imgProfile"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:src="#drawable/profile_picture"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imgProfileBackground"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:src="#drawable/background_profile"/>
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="#string/choose_picture"
android:id="#+id/buttonSelectPicture"
android:background="#drawable/btn_change_picture"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal|center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="25dp"/>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="119dp"
android:weightSum="1"
android:layout_marginTop="15dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.76"
android:baselineAligned="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:id="#+id/textView"
android:layout_weight="0.06"
android:layout_marginLeft="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/name"
android:layout_weight="0.33"
android:layout_marginRight="10dp"
android:background="#android:color/transparent"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="42dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name"
android:id="#+id/textView2"
android:layout_weight="0.28"
android:layout_marginLeft="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/lastName"
android:layout_weight="3.98"
android:layout_marginRight="10dp"
android:background="#android:color/transparent"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.88">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone"
android:id="#+id/textView3"
android:layout_weight="0.01"
android:layout_marginLeft="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="36dp"
android:id="#+id/phone"
android:layout_weight="0.06"
android:layout_marginRight="10dp"
android:background="#android:color/transparent"/>
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="40dp"
android:text="#string/upload"
android:id="#+id/updateButton"
android:background="#drawable/btn_save_changes"
android:textColor="#FFFFFF"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"/>
<RelativeLayout android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</RelativeLayout>
</LinearLayout>
</ScrollView>
The line that has layout_alignParentBottom is forcing the button to stay at the bottom of the parent element, no matter how you set the margins.
You can take out the line with android:layout_alignParentBottom, and replace that line with android:layout_below"#+id/imgProfile". Then you will be able to use android:layout_marginTop successfully.
Here is an example of the corrected code for the layout that you want:
<Button
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="choose picture"
android:id="#+id/buttonSelectPicture"
android:background="#android:color/holo_blue_light"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal|center"
android:layout_below="#+id/imgProfile"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="25dp"/>

Categories

Resources