Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set XML fullscreen in Android

Tags:

android

xml

How do I create a full screen mode in XML irregardless of how small what contents are in it?

Here's my "show.xml" code:

<LinearLayout android:orientation="vertical"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_gravity="center">    

<Button android:id="@+id/ok_btn" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:typeface="sans" android:text="ok"></Button>

</LinearLayout>

I want to display it like another full screen page, with black background, like a main.xml. In this case, its like a pop-up screen. Removing or changing the android:layout_width and android:layout_heigh don't work. help please! :(

like image 601
Sushi Avatar asked Oct 21 '11 00:10

Sushi


People also ask

How do I put Android in fullscreen mode?

Using Android Studio (current version is 2.2. 2 at moment) is very easy to add a fullscreen activity. See the steps: Right click on your java main package > Select “New” > Select “Activity” > Then, click on “Fullscreen Activity”.

Can we use XML for Android?

Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace.

What is XML based layout in Android?

XML-Based Layouts in Android In Android, an XML-based layout is a file that defines the different widgets to be used in the UI and the relations between those widgets and their containers. Android treats the layout files as resources. Hence the layouts are kept in the folder reslayout.

What is view in Android XML?

A View occupies a rectangular area on the screen and is responsible for drawing and event handling. Views are used for Drawing Shapes like Circles,Rectangles,Ovals etc . Just Use View with background and apply a Shape using Custom Drawable.


1 Answers

Afaik you can't do fullscreen in xml. You have two choices:

  1. AndroidManifest.xml in activity's section
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
  1. in onCreate() before calling setContentView
requestWindowFeature( Window.FEATURE_NO_TITLE );

getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,
                      WindowManager.LayoutParams.FLAG_FULLSCREEN );
like image 102
Martin Nuc Avatar answered Sep 24 '22 01:09

Martin Nuc