<?xml version="1.0" encoding="utf-8"?>
<me.didik.component.StickyNestedScrollView
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:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="#color/black"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:fillViewport="false"
app:layout_constraintStart_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#id/pager"
android:tag="sticky"
tools:ignore="MissingConstraints" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tab_layout"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
</me.didik.component.StickyNestedScrollView>
ViewPager height does not change.
Height is always set to 0.
But if you force the height it will be set.
I want to write both tablelayout and scrollview.
Please help me....
you need to add attribute
app:layout_constrainedHeight="true"
<androidx.viewpager.widget.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constrainedHeight="true"
android:background="#color/colorPrimary"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tab_layout"
tools:ignore="MissingConstraints" />
also setting the height 0dp instead 0 will work
Related
I'm trying to create an app with Floating Action Button at top of my RecycleView on Fragment, can someone guide me how can i put my floating action button that will overlap my RecycleView without putting it on MainActivity?
i want to remove this part
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_weight="4"
android:layout_height="0dp"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</LinearLayout>
I am adding an example code (as same as your code with the expected result) using ConstraintLayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/floating_action_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_margin="16dp"
android:backgroundTint="#color/borderColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#drawable/ic_add"
app:tint="#FFFFFF" />
</androidx.constraintlayout.widget.ConstraintLayout>
Try like below:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</RelativeLayout>
Result:
Try this code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#layout/app_toolbar"
android:layout_weight="0.6"
android:orientation="vertical"
android:stateListAnimator="#null">
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_asset_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:background="#android:color/transparent"
android:backgroundTint="#color/white"
android:src="#drawable/icon_camera"
app:rippleColor="#color/white" />
<android.support.v7.widget.RecyclerView
android:id="#+id/messages"
android:layout_width="match_parent"
android:layout_height="451dp"
android:layout_weight="1"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
Image
The pink box is a tablelayout and the spreadsheet is a constraint layout. I have tried using margins and constraints but when I run it on different phones, the pink box always ends up outside or will be too small. Code right now:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/game1"
android:maxWidth="500dp">
<TableLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="44dp"
android:layout_marginLeft="44dp"
android:layout_marginTop="147dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="1dp"
android:layout_marginBottom="51dp"
android:layout_weight="1"
android:foreground="#CBD81B60"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:visibility="visible">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
you can use constraintlayout.widget.Guideline and use layout_constraintGuide_percent like this
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/game1">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".2"/>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent=".1"/>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".9"/>
<TableLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:foreground="#CBD81B60"
app:layout_constraintBottom_toBottomOf="#id/guide_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="#id/guide_start"
app:layout_constraintTop_toTopOf="#id/guide_top"
app:layout_constraintVertical_bias="0.0"
tools:visibility="visible">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
you can change layout_constraintGuide_percent as you wish
hope this help
So I am trying to make an application but When I try to use multiple layouts. But they are overlapping on one another.
These are the Layout files for the design
this is nav_drawer
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
android:background="#429B50"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
this is nav_home
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
This is activity home
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/nav_drawer"/>
<include layout="#layout/nav_home"/>
</RelativeLayout>
I know it looks messy with multiple layout files but that's because i was trying different ways to solve the problem. Would really appreciate the help
In your activity home, which is a RelativeLayout, you include these:
<include layout="#layout/nav_drawer"/>
<include layout="#layout/nav_home"/>
You must use the proper attributes for these layouts to be positioned correctly.
If you want the button to be at the bottom of your activity, do this:
<include layout="#layout/nav_home"
android:layout_alignParentBottom="true"/>
You may have to set other attributes too.
Also in nav_home.xml I think you should set android:layout_height="wrap_content" at least for the height, maybe for width too and remove all these attributes that apply only inside a ConstraintLayout:
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button" />
</RelativeLayout>
If you want the Button at the bottom right corner then you can use one of these 2 ways:
You can use constraint layout and add these 2 constraints to Button
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Modify Relative layout and add this
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
<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:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Hope that will resolve your problem... :)
In my CountryActivityInfo.java I have a collapsing toolbar with both width and height set to match-parent so it can occupy the whole phone screen. When I scroll up the toolbar gets a fixed 200dp height.
Right now, it looks like this:
I want to display, in that white screen that appears when the toolbar is collapsed, a vertical scroll view with a text view inside. How can I do that? I've tried this way:
<android.support.design.widget.AppBarLayout
android:id="#+id/testeparainfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/actionBarDivider">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/backgroundcollapsedtoolbarinfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<ImageView
android:id="#+id/imgCountryInfoFoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="#+id/imgCountryInfoEscuro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="#drawable/background_pais_info"
android:scaleType="centerInside" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbaridinfo"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<TextView
android:id="#+id/txtNomePaisInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="10dp"
android:text="TextView"
android:textColor="#android:color/background_light"
android:textSize="35sp"
app:layout_anchor="#+id/testeparainfo"
app:layout_anchorGravity="left|bottom" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/txtInfoPais"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/btnArrowBackWhite"
android:layout_marginBottom="111dp"
android:text="TextView"
android:textColor="#android:color/background_light"
android:textSize="15sp"
android:visibility="invisible"
app:layout_anchor="#+id/imgCountryInfoFoto"
app:layout_anchorGravity="bottom|center" />
</LinearLayout>
</ScrollView>
But, when I do this, the text view gets inside the collapsing toolbar and gets collapsed with the toolbar.
By the way, all the XML is wrapped up in a Coordinator Layout!!!
Change the root to CoordinatorLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_scrolling" />
</android.support.design.widget.CoordinatorLayout>
and then in content_scrolling.xml use NestedScrollView and app:layout_behavior="#string/appbar_scrolling_view_behavior" use this property for proper behaviour.
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
...
</android.support.v4.widget.NestedScrollView>
Add app:layout_behavior="#string/appbar_scrolling_view_behavior" inside your ScrollView.
Replace this code
you have to add app:layout_behavior="#string/appbar_scrolling_view_behavior" in your ScrollView.
<ScrollView
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/txtInfoPais"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/btnArrowBackWhite"
android:layout_marginBottom="111dp"
android:text="TextView"
android:textColor="#android:color/background_light"
android:textSize="15sp"
android:visibility="invisible"
app:layout_anchor="#+id/imgCountryInfoFoto"
app:layout_anchorGravity="bottom|center" />
</LinearLayout>
</ScrollView>
I am working with AndroidStudio 3.0 and I am creating a TabbedActivity with Fragments using Java.
For realizing the following design:
sketch
i sourrounded the ViewPager with a RelativeLayout in order to display a static content object (TextView) below the ViewPager. For this I am using the attribute
android:layout_below="#id/container"
Unfortunately, the TextView never gets shown.
By fuzzling around i realized, that when setting the
android:layout_height="100dp"
of the ViewPager to a fixed value it will be displayed.
As I am a beginner to Android I am unsure how to handle this issue. Is it not possible to use the layout_below attribute when working with ViewPagers? Or do i have to set a fixed value for them?
Is there another solution to achieve what i want - simply showing a static content below a 'TabControl'?
Here is my complete XML code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="#string/app_name">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_1" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_2" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_3" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" >
</android.support.v4.view.ViewPager>
<TextView
android:id="#+id/static_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="This is the Textiew that is not shown!"
android:layout_below="#id/container"
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Thank You very much!
Change this part of your code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" >
</android.support.v4.view.ViewPager>
<TextView
android:id="#+id/static_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="This is the Textiew that is not shown!"
android:layout_below="#id/container"
/>
</RelativeLayout>
I would replace this with a vertical LinearLayout. This allows you to give some space to the TextView and then give the rest of the space to the ViewPager, which a RelativeLayout won't allow.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<TextView
android:id="#+id/static_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="This is the Textiew that is not shown!"/>
</LinearLayout>