Change the system display size programmatically Android N

Related searches

Background: Android N comes with a feature to change system Display Size from settings, in addition to the previously present feature of changing Font Size.

Change Display Size:

Image Source:


If an app has android.permission.WRITE_SETTINGS permission to change the settings, there are ways to change the system font size programatically as mentioned in How to programmatically change font settings of Device: font style and font size?. However I couldn't find a way to change the display size programmatically. Is it possible?

What I've tried?

I've checked the possible options in the list of Settings.System convenience functions provided for changing settings programmatically.


I've opened a feature request for the same here: . If you feel it would be useful please star it.

Android N allows you to change your device's display size [Diving , Change display size. To make items on your screen smaller or larger: Open your device's Settings app Settings app; Tap Accessibility, then tap Display size� The font size setting doesn't apply to the Google Chrome app, which has its own text scaling control. Change display size. To make items on your screen smaller or larger: Open your device's Settings app ; Tap Accessibility, then tap Display size; Use the slider to choose your display size; Some apps on your screen might change position.

In manifest, under application: android:configChanges="density"

In an activity/application:

public void adjustDisplayScale(Configuration configuration) {
    if (configuration != null) {
        Log.d("TAG", "adjustDisplayScale: " + configuration.densityDpi);
        if(configuration.densityDpi >= 485) //for 6 inch device OR for 538 ppi
            configuration.densityDpi = 500; //decrease "display size" by ~30
        else if(configuration.densityDpi >= 300) //for 5.5 inch device OR for 432 ppi
            configuration.densityDpi = 400; //decrease "display size" by ~30
        else if(configuration.densityDpi >= 100) //for 4 inch device OR for 233 ppi
            configuration.densityDpi = 200; //decrease "display size" by ~30
        DisplayMetrics metrics = getResources().getDisplayMetrics();
        WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        metrics.scaledDensity = configuration.densityDpi * metrics.density;
        this.getResources().updateConfiguration(configuration, metrics);

Call it just after super.onCreate(..):

protected void onCreate(Bundle savedInstanceState) {
    adjustDisplayScale( getResources().getConfiguration());

This will set the Display Size in-between the "Smaller" and "Small" settings of "Display Size" overriding any Display Size settings set by user. It self-adjusts correctly for 4in, 5.5in, 6in etc devices.. but I'm sure there would a better way than using those if statements.

Font size and display size, Preview videos � Recommendations in Android N and earlier updates, the device needs to enable the appropriate system settings, such as GPS or Wi-Fi scanning. Rather This approach is appropriate for mapping apps that display the location in real time. Prompt the user to change location settings. Even though most Android devices today come with good resolution and pixel density, sometimes you may need to change resolution of your display for various reasons. Gaming is the most common reason. Sometimes you may want to play a game, but it’s putting strain on your processor and causing your game to lag .

While referring Settings.System , there is a [putConfiguration(ContentResolver cr, Configuration config)](, android.content.res.Configuration)) method. Use of this method is:

Convenience function to write a batch of configuration-related settings from a Configuration object.

In Configuration

This includes both user-specified configuration options (locale list and scaling) as well as device configurations (such as input modes, screen size and screen orientation).

Set configuration with SCREENLAYOUT_SIZE_MASK values for screen size. It is:


I hope its helps you.

Change location settings, Also, to learn about areas where platform changes may affect your apps These displays are treated as a variant of displays with display cutouts. getWaterfallInsets() to get exact dimensions of the waterfall inset. Bubbles are now available to developers to help surface conversations across the system. Android pearls: Set size to a View in DP programatically. each devices may have a different number of pixels per inch and may have more or fewer total pixels available on the screen.

Features and APIs Overview, Preview videos � Recommendations in Android N and earlier Android runs on a variety of devices that have different screen sizes and pixel densities. The system performs basic scaling and resizing to adapt your user interface to bar), and window configuration changes (such as when the user enables� A 4 inch display on your phone could have more or less pixels then say a 26 inch TV. If Im understanding correctly he wants to detect which of the size groups the current screen is, small, normal, large, and extra large. The only thing I can think of is to detect the pixel density and use that to determine the actual size of the screen.

Screen compatibility overview, How to get Android Screen Size in pixels and inches programmatically In this tutorial, we are going to learn how to get android screen size in pixels and inches programmatically. This will be a simple tutorial but you will find it useful in different areas during android application development.

With Android 8.0 (API level 26) and higher, you can instruct a TextView to let the text size expand or contract automatically to fill its layout based on the TextView's characteristics and boundaries.

  • @alanv Thanks for looking into it. It doesn't seem like it works. Can you please guide that Android Open Source Project - Issue Tracker is the right place to open the feature request for the same or do we need to request it somewhere else? Thanks pRaNay for the effort to help. Unfortunately, it doesn't seem to work.