Issue
I am developing an app that contains many text. I got viewpager with fragments that contain textviewes. I want this textview to fit all system window (behind status and navigation bar also). I am using fullscreen activity for this
Fragment XML
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="New Text"
android:id="@+id/page_content"
android:textSize="25dp"
android:padding="15dp"
android:allowUndo="true"
android:background="#ffffff" />
Activity XML
<FrameLayout 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:fitsSystemWindows="true"
android:background="#ffffff"
tools:context="tsk.dan.librarian.activity.reader">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/fullscreen_content"
android:layout_gravity="center_horizontal|top">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayout"
android:layout_alignParentStart="true"
android:layout_above="@+id/relativeLayout2" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tester1"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:padding="15dp"
android:textSize="25dp"
android:background="@android:color/transparent" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</android.support.v4.view.ViewPager>
<Button
android:layout_width="97dp"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button4"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_gravity="right|top" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/fullscreen_content_controls"
android:layout_gravity="center_horizontal|top">
<RelativeLayout
android:background="@drawable/reader"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/relativeLayout4"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal|bottom">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="25dp"
android:id="@+id/progressBar2"
android:maxHeight="15dp"
android:layout_below="@+id/textView5"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_marginBottom="5dp"
/>
<TextView
android:textAlignment="center"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=" "
android:id="@+id/textView5"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp" />
</RelativeLayout>
<RelativeLayout
android:background="@drawable/reader"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/relativeLayout5"
android:layout_below="@+id/dsa"
android:layout_alignParentStart="true"
android:layout_gravity="left|top">
<ImageView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:id="@+id/imageView5"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:src="@mipmap/open"
android:paddingRight="0dp"
android:layout_marginLeft="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp" />
</RelativeLayout>
</FrameLayout>
Styles XML
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
Help me please!
Solution
The answer was very simple !If you want your content fullscreen(under status and navigation bar), you need to use FrameLayout without this line
android:fitsSystemWindows="true"
So if you want such full screen content just delete this line or don't add it.
Answered By - Dan Tsk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.