Wie kann ich die Hintergrundfarbe anhand der Geräteausrichtung in einer Android-App ändern?Hintergrund basierend auf der Geräteausrichtung ändern
Wenn das Gerät vertikal (Hochformat) ist, wechseln Sie zu Gelb;
Wenn es horizontal (Landschaft) ist, wechseln Sie zu grün.
es hat nicht funktioniert, wenn ich die App stoppt das Gerät Orientierung ändern, hier mein Code: 'protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); Ll = (LinearLayout) this.findViewById (R.id.layo); txt = (Textansicht) findViewById (R.id.text); if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { Ll.setBackgroundColor ((Color.GREEN)); } else { Ll.setBackgroundColor ((Color.BLACK)); } ' –