StatusBar Transparent in Fragment Xamarin.Android - android-fragments

I have a single Activity with a FrameLayout that contains my Fragments.
I want to set the StatusBar transparent , but i cant make it , i have no problems to set StatusBar transparent in a single Activity but not in a Fragment
This is what i want to achieve
activity_main.axml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_frame"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/content_frame"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:layout_marginBottom="53dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="#+id/navigation_frame"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="left|start" />
</android.support.v4.widget.DrawerLayout>
fragment
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="#+id/darthvader2"
android:src ="#drawable/Xamarin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

I found the answer , remove the android:fitsSystemWindows="true" in the activity_main.axml

Related

collasping and expanding LinearLayout instead of TabLayout inside AppBarLayout

I have used LinearLayout instead of Tablayout inside AppBarLayout. Please first watch this video link.
I want the same collapsing and extending effect for this LinearLayout as TabLayout has (in this video) when scroll event occurs. I also want toolbar to
to be fixed on the top. just Like the video demo.
My code is below.
<?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="com.cnpinyin.lastchinese.activities.ViewPagerSlider">
<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="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20dp"
android:text="Toolbar title"
android:textColor="#000"
/>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="collapse and expands text"/>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<com.xxx.activities.extras.CustomViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#eeeeee"
android:padding="0dp"
android:layout_below="#id/appbar"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Is it possible to do as I want?

Space between toolbar (in Activity) and tablayout (in fragment)

I am developing an app in which I have to implement tablayout in a fragment, while the toolbar itself remains on the main frame of the activity. note that, I need multiple transactions of fragment and only one has tablayout. The code works completely fine. But the problem is there is a gap between the toolbar and tablayout on the first run. If I chage the fragment and get back to it, the gap is gone. How can I fix this??
enter image description here
In the Activity:
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="thanatos.perkyrabbit.edumanager.Activities.GuardianPrivilegesActivity"
tools:showIn="#layout/activity_guardian_privileges">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/nav_menu_guardian_privileges"/>
</android.support.v4.widget.DrawerLayout>
in the fragment
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="thanatos.perkyrabbit.edumanager.Fragments.Guardian.StudentProgressFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:tabTextAppearance="?android:attr/textAppearanceMedium"
app:tabTextColor="#ffffff"
android:layout_height="?android:actionBarSize"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/student_progress_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:background="#android:color/white"/>
</LinearLayout>
In the StudentProgressFragment xml, change
android:fitsSystemWindows="true"
to
android:fitsSystemWindows="false"

How to calling TabLayout into FrameLayout with Fragment

I want to make an application like on the following photo. I have a Tab Layout and Navigation Drawer in the my Main Activity.
I want to make as Frame Layout the field with red border. I mean my Tab Layout will be in Fragment's xml and i will get it into Frame Layout.
Here is my activity_main.xml.
activity_main.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>
I have try a few methods but I have lost scrolling effects and toolbar is not hidden.
Thanks for your helping.
Try my example on github https://github.com/jandrop/TabLayoutFragment, I think that solves your question.

adview not showing with bottom on linearlayout

I want to add applications to the ad. But I fail I want to add about the position advertised. Codes are as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:layout_gravity="center_vertical|center_horizontal"
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
<LinearLayout
android:layout_gravity="bottom"
android:orientation="horizontal"
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"></LinearLayout>
</LinearLayout>
I want adview showing bottom on linearlayout. Adview # + id /adLayout will be displayed on the Layout
Please help me.
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:orientation="vertical"
tools:context="info.androidhive.materialtabs.fragments.OneFragment">
<TextView
android:id="#+id/tarih"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="Header"
android:textColor="#04B038"
android:textSize="15dp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/adLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#ff0000"
android:orientation="horizontal"></LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adLayout"
android:layout_below="#+id/tarih">
<ListView
android:id="#+id/olaylar_liste"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<ProgressBar
android:id="#+id/progress_olaylar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</FrameLayout>
</RelativeLayout>

Support Toolbar's custom view not using full width

I'm using support v7's toolbar. I added a custom view, but the custom view doesn't seem to obey "match_parent". It would only stretch as far as the first icon it sees. Does anyone know a fix to this? Or is the toolbar not meant to be used this way?
My code:
<FrameLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context="com.example.activities.ToolbarActivity"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="100dp"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/light_gray"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:gravity="bottom"
android:clipChildren="false"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#color/green"
>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</FrameLayout>
I have succeed with the approach in Simon's link:
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context="com.example.activities.ToolbarActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="100dp"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/light_gray"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="70dp"
android:background="#color/green">
</RelativeLayout>
</RelativeLayout>

Resources