Menyembunyikan Title Bar dan Contoh Layar Penuh (Android Studio)
September 08, 2020
Add Comment
Dalam contoh ini, kita akan menjelaskan cara menyembunyikan bilah judul dan cara menampilkan konten dalam mode layar penuh.
RequestWindowFeature(Window.FEATURE_NO_TITLE) metode aktivity harus dipanggil untuk menyembunyikan judul. Tapi, itu harus sebelum metode setContentView.
Dengan memanggil hide() ini akan menyembunyikan ActionBar atau bilah judul.
File : activity_main.xml
# Kode yang menyembunyikan bilah judul aktivitas
Metode getSupportActionBar() digunakan untuk mengambil contoh ActionBar class.Dengan memanggil hide() ini akan menyembunyikan ActionBar atau bilah judul.
requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title getSupportActionBar().hide(); //hide the title bar
# Kode yang memungkinkan mode aktivitas layar penuh
Metode setFlags() class window digunakan untuk menampilkan konten dalam mode layar penuh. Anda perlu melewati konstanta WindowManager.LayoutParams.FLAG_FULLSCREEN dalam metode setFlags.this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //show the activity in full screen
Menyembunyikan Title Bar dan Contoh Layar Penuh (Android Studio)
Mari kita lihat kode lengkap untuk menyembunyikan bilah judul di android.activity_main.xml
File : activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="first.android.com.hidetitlebar.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout>
Activity class
File : MainActivity.javapackage first.android.com.hidetitlebar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title getSupportActionBar().hide(); // hide the title bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen setContentView(R.layout.activity_main); } }
0 Response to "Menyembunyikan Title Bar dan Contoh Layar Penuh (Android Studio)"
Posting Komentar