❶ 怎樣隱藏安卓機下方的三個虛擬鍵
Android 隱藏虛擬按鍵,可以使用谷歌官方提供的api里的SYSTEM_UI_FLAG_HIDE_NAVIGATION 這個標志位來完成,如下代碼:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class HideTestActivity extends Activity implements OnClickListener{
View main ;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
main = getLayoutInflater().from(this).inflate(R.layout.main, null);
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);//設置虛擬鍵隱藏
main.setOnClickListener(this);//點擊事件
setContentView(main);
}
@Override
public void onClick(View v) {
int i = main.getSystemUiVisibility();
if (i == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);//設置通知欄和虛擬鍵盤隱藏
} else if (i == View.SYSTEM_UI_FLAG_VISIBLE){
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);//設置通知欄隱藏
} else if (i == View.SYSTEM_UI_FLAG_LOW_PROFILE) {
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);//設置虛擬鍵隱藏
}
}
}