Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the display and concealment function of virtual navigation keys in Android

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the Android how to achieve virtual navigation keys show hidden function of the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that you read this Android how to achieve virtual navigation keys show hidden function of the article will have a harvest, let's take a look at it.

The code is as follows:

Package test.lb.com.myapplication;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Button;public class MainActivity extends Activity implements View.OnClickListener {boolean isnight = false; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); Button nightbutton = (Button) findViewById (R.id.nightbutton); Button hidebutton = (Button) findViewById (R.id.hidenav); Button fullbutton = (Button) findViewById (R.id.full) Button fullonly = (Button) findViewById (R.id.fullonly); nightbutton.setOnClickListener (this); hidebutton.setOnClickListener (this); fullbutton.setOnClickListener (this); fullonly.setOnClickListener (this);} @ Override public void onClick (View v) {switch (v.getId ()) {case R.id.nightbutton: if (isnight) {v.setSystemUiVisibility (View.SYSTEM_UI_FLAG_VISIBLE) } else {/ / Night mode, the color of the system controls will darken v.setSystemUiVisibility (View.SYSTEM_UI_FLAG_LOW_PROFILE);} isnight =! isnight; break; case R.id.hidenav: / / hide the virtual button, click to reappear v.setSystemUiVisibility (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); break Case R.id.full: / / will not move our control v.setSystemUiVisibility (View.SYSTEM_UI_FLAG_LAYOUT_STABLE | / / hide the system status bar while hiding the system controls). If Window.FEATURE_ACTION_BAR_OVERLY is set and hide Actionbar View.SYSTEM_UI_FLAG_FULLSCREEN at the same time | / / this will hide all the system controls on the screen View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) Break; case R.id.fullonly: v.setSystemUiVisibility (View.SYSTEM_UI_FLAG_FULLSCREEN);}

The key part of the code is already at the top, so let's talk about a few FLAG:

After setting 1.View.SYSTEM_UI_FLAG_LOW_PROFILE this Flag, you will find that the background of the system controls in the entire screen, including the control itself, will dim or disappear, such as some icons in the status bar, but this is only the system status bar, virtual keys, etc. enter night mode, app internal controls will not enter night mode, this later have time to study how to implement night mode in the application.

2.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION, setting this Flag can be a virtual button for dynamic display and hiding, because the virtual button will occupy the screen control, so the display and hiding of the virtual button may affect the position of your control in the current interface. At this time, you may need to set another FLAG, this FLAG is View.SYSTEM_UI_FLAG_LAYOUT_STABLE Setting this FLAG will make your controls no longer affected by the display or hiding of virtual keys.

3.View.SYSTEM_UI_FLAG_FULLSCREEN, this Flag should be a commonly used Flag. After setting, controls such as the status bar will be shielded to make your interface full screen display (without hiding virtual keys), but if there are related contents such as actionbar and activitytitle, these will still be displayed. If Window.FEATURE_ACTION_BAR_OVERLY is set, while hiding the status bar, the actionbar will also be hidden. If you want to hide title, you need to set Window.FEATURE_NO_TITLE

How to call up a virtual button with physical buttons

1. By modifying the build.prop to call up the virtual button, the path is under system/, in which you can find build.prop to open and you can see qemu.hw.mainkeys=1 or qemu.hw.mainkeys=0. When qemu.hw.mainkeys=1 takes effect, the physical keyboard takes effect, and when qemu.hw.mainkeys=0, the virtual keyboard is displayed. Clicking on the physical keyboard does not work at this time.

This is the end of the article on "how to achieve the display and hiding function of virtual navigation keys in Android". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to achieve the display and hiding function of virtual navigation keys in Android". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report