Red de conocimiento informático - Conocimiento informático - Cómo configurar la interfaz de Android en orientación horizontal

Cómo configurar la interfaz de Android en orientación horizontal

Pantalla completa

Agregue el siguiente código antes de llamar a setContentView(myview) en el método onCreate de la actividad

requestWindowFeature(Window.FEATURE_NO_TITLE); //Ocultar título

p>

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

?WindowManager.LayoutParams.FLAG_FULLSCREEN,

?WindowManager.LayoutParams.FLAG_FULLSCREEN ); //Establece la pantalla completa

Pantalla horizontal

Modifica el método onResume de la actividad según el ejemplo de código siguiente

@Override

protected void onResume() {

/**

?* Establecer en horizontal

?*/

if(getRequestedOrientation() ! =ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {

?setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

}

super.onResume(); }

O agregue el atributo android: screenOrientation al nodo Actividad en el archivo de configuración (el paisaje es horizontal, el retrato es vertical)

android.launchMode="singleTask";