Skip to content Skip to sidebar Skip to footer

Make An Android Activity Full Screen Over A Button

Im new on android development and I want to know how can I make an android activity fullscreen via a Icon placed on toolbar. Thank You. Please click on link for example image: Clic

Solution 1:

I think this previous post may give you what you are looking for:

Fullscreen Activity in Android?

From post mentioned above:

You can do it programatically:

public class ActivityName extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // remove title
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
}
}

Or you can do it via your AndroidManifest.xml file:

<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>

How your code should differ:

public class ActivityName extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // remove title
    Button x = findViewById(R.id.yourButton);
       x.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
             WindowManager.LayoutParams.FLAG_FULLSCREEN);
             setContentView(R.layout.main);
          }
       });
}
}

This would link your button with this code.


Post a Comment for "Make An Android Activity Full Screen Over A Button"