Header ads

Header ads
» » Hide Title Bar

Ví dụ dấu thanh tiêu đề trong android

Trong ví dụ này, chúng tôi sẽ giải thích cách ẩn thanh tiêu đề và cách hiển thị nội dung ở chế độ toàn màn hình.
Gọi phương thức requestWindowFeature(Window.FEATURE_NO_TITLE) của Activity để ẩn thanh tiêu đề. Nhưng nó phải được thêm trước phương thức setContentView.

  @Override        protected void onCreate(Bundle savedInstanceState) {            super.onCreate(savedInstanceState);                        requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title not the title bar                        setContentView(R.layout.activity_main);                  }    }  

Phương thức setFlags () của lớp Window được sử dụng để hiển thị nội dung ở chế độ toàn màn hình. Bạn cần phải truyền hằng số WindowManager.LayoutParams.FLAG_FULLSCREEN  trong phương thức setFlags.

  @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);                requestWindowFeature(Window.FEATURE_NO_TITLE);        //code that displays the content in full screen mode        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                    WindowManager.LayoutParams.FLAG_FULLSCREEN);//int flag, int mask                setContentView(R.layout.activity_main);          }  

Ví dụ ẩn thanh tiêu đề trong Android

Chúng ta xem toàn bộ mã nguồn ẩn thanh tiêu đề

File: activity_main.xml

  <RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"        xmlns:tools="http://schemas.android.com/tools"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:paddingBottom="@dimen/activity_vertical_margin"        android:paddingLeft="@dimen/activity_horizontal_margin"        android:paddingRight="@dimen/activity_horizontal_margin"        android:paddingTop="@dimen/activity_vertical_margin"        tools:context=".MainActivity" >            <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="@string/hello_world" />        </RelativeLayout>  

File: MainActivity.java


Download ví dụ


Kết quả: Chỉ ẩn thanh tiêu đề

Kết quả: Ẩn thanh tiêu đề và cho phép toàn (full) màn hình



Cập nhật công nghệ từ Youtube tại link: https://www.youtube.com/channel/UCOxeYcvZPGf-mGLYSl_1LuA/videos
Để tham gia khóa học công nghệ truy cập link: http://thuvien.hocviendaotao.com
Mọi hỗ trợ về công nghệ email: dinhanhtuan68@gmail.com

About Học viện đào tạo trực tuyến

Xinh chào bạn. Tôi là Đinh Anh Tuấn - Thạc sĩ CNTT. Email: dinhanhtuan68@gmail.com .
- Nhận đào tạo trực tuyến lập trình dành cho nhà quản lý, kế toán bằng Foxpro, Access 2010, Excel, Macro Excel, Macro Word, chứng chỉ MOS cao cấp, IC3, tiếng anh, phần mềm, phần cứng .
- Nhận thiết kế phần mềm quản lý, Web, Web ứng dụng, quản lý, bán hàng,... Nhận Thiết kế bài giảng điện tử, số hóa tài liệu...
HỌC VIỆN ĐÀO TẠO TRỰC TUYẾN:TẬN TÂM-CHẤT LƯỢNG.
«
Next
Bài đăng Mới hơn
»
Previous
Bài đăng Cũ hơn