2017-12-09 2 views
0

Hier ist ein Problem mit der Aktionsleiste im Querformat (im Hochformat).Deaktivieren der Titelleiste im Querformat

Ich poste ein Beispiel meiner Manifest-XML-Datei, die versucht hat, die Informationen in anderen Threads.

<?xml version="1.0" encoding="utf-8"?> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

mein styles.xml

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light"> 
    <!-- Primary theme color of the app (sets background color of app bar) --> 
    <item name="colorPrimary">#ffcfcf</item> 
    <!-- Background color of buttons in the app --> 
    <item name="colorButtonNormal">#ff8383</item> 
</style> 

<style name="AppThemeNoActionBar" parent="AppTheme"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

ein Ausschnitt aus meinem Land \ activity_main.xml

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:style="@style/AppThemeNoActionBar"> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/love3" 
    android:scaleType="centerCrop"/> 

...

Ich habe versucht, die Eltern in styles.xml von AppTheme zu Theme.AppCompat.Light vergeblich zu ändern.

Porträt Layout xml nicht über android: style = "@ style/AppThemeNoActionBar"

Alle Zeiger wäre toll!

Antwort

0

Versuchen Sie, diese in onCreate Funktion unter setContentView

if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { 
     getSupportActionBar().hide(); 
    } 
0

Sie können es so machen,

if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { 
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 
else { 
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 
+0

Wäre das Java anstelle der oben oder zusätzlich verwendet werden? – fruitcakej

+0

Sie können dieses Code-Snippet in Ihre MainActivity-Klasse einfügen. –