1

Estoy modificando una splashscreen, me interesa fijar que se visualice en vertical para smartphones y en horizontal en tabletas.

2 respuestas 2

2

Puedes usar primeramente un método para detectar si el dispositivo es Tablet o télefono:

public static boolean isTablet(Context ctx){
                return (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

por lo tanto se realizaría la validación de esta forma, mediante el uso del método setRequestedOrientation() de tu Activity para lograr fijar la pantalla:

if(isTablet(getApplicationContext()){
//Es tablet, fija orientación horizontal.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}else{
//Es teléfono, fija orientación vertical.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
0

También he estado probando valores de android:screenOrientationdentro del AndroidManifest.xmly una de la posibilidades es poner nosensor.

  • smartphones se fija en vertical portrait
  • tabletas se fija en horizontal landscape
  • phalbets, por determinar

Si alguien tiene una plalbet que pruebe y comente como se le visualiza si en vertical o en horizontal.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.