0% found this document useful (0 votes)
15 views1 page

Practical NO 4

This document contains a Java code snippet for an Android application, specifically the MainActivity class. It demonstrates how to enable edge-to-edge display and apply window insets to adjust padding for system bars. The code uses AndroidX libraries to manage window insets and ensure proper layout adjustments.

Uploaded by

Pratiksha Wagh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Practical NO 4

This document contains a Java code snippet for an Android application, specifically the MainActivity class. It demonstrates how to enable edge-to-edge display and apply window insets to adjust padding for system bars. The code uses AndroidX libraries to manage window insets and ensure proper layout adjustments.

Uploaded by

Pratiksha Wagh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Practical NO 4

package com.example.mylogin;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
}

You might also like