2017-02-01 5 views
-1

Ich habe gerade ein neues Projekt in Android Studio v2.2.3 erstellt - ein Projekt Targeting API Level 15 und mit einer leeren Aktivität zu starten.Wo in Android-Projekt Menü für Aktivität

Die XML für diese Aktivität ist:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_starting" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.bfsog.apps.testapp.StartingActivity"> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Lorem ipsum"/> 

</RelativeLayout> 

Im Vorschaufenster und wenn ich diese laufen, am oberen Rand des Bildschirms gibt es mit dem Namen meiner app und dann darunter ein blauer Balken ist, meine Textansicht.

Ich habe dann eine neue leere Aktivität, mit der gleichen XML aber etwas anders Text:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_display_notification" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.bfsog.apps.testapp.SecondActivity"> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="ipsum lorem"/> 

</RelativeLayout> 

nun im Vorschaufenster für die zweite Aktivität ist es nicht die horizontale blaue Leiste am oberen Rande hat.

Wo ist das angegeben?

Edit: Mein Manifest:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.bfsog.apps.testapp"> 

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

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".SecondActivity" 
     android:theme="@style/AppTheme"> 

    </activity> 
</application> 
</manifest> 

Die erste Aktivität ist nicht festgelegt, das Thema, aber es wird die blaue Leiste. Die zweite Aktivität gibt das Thema an, wird jedoch nicht angezeigt.

+1

Es ist ActionBar, wofür brauchen Sie Hilfe? Versucht es zu entfernen? – OBX

+0

Werkzeuge: Kontext, in der Regel Arten die Themen für diese Aktivität erforderlich, legen Sie das gleiche Thema für die zweite Aktivität in Manifest und sehen, sonst oben, sollte es so etwas wie Themen, überprüfen Sie es einmal – Redman

+0

Sie müssen Themen im Stil definieren. XML. –

Antwort

0

Sie müssen das gleiche Thema auf beiden Aktivitäten verwenden. Wahrscheinlich kopieren Thema von der ersten Aktivität zu einem anderen. Oder Erstellen Sie eine neue wie folgt.

<style name="AppTheme" parent="AppTheme.Base"/> 

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 

dann auf ActivityManifest.xml

<activity 
      android:theme="@style/AppTheme" 
      android:name=".SecondAct" > 
+0

Bitte beachten Sie meine Bearbeitung, ich enthalten Manifest – andrewb

0

wird ActionBar genannt

in Ihrer res/Werte/Stile:

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> //this is the action bar background color 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

, um es Ihre benutzerdefinierten Designs hinzufügen zu ändern;

<style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light"> 
     <item name="android:actionBarStyle">@style/MyActionBarTheme</item> 
    </style> 

    <style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">ANY_HEX_COLOR_CODE</item> 
    </style> 

Aktionsleiste zeigen:

in manifest:

<activity 
     android:name=".SecondActivity" 
     android:label="@string/app_name" //this is the text showing on action bar 
     android:theme="@style/AppTheme"></activity> //use theme 

Sie benutzerdefinierte Aktionsleiste mit unterschiedlicher Farbe zeigen können:

android:theme="@style/MyCustomTheme" 

Aktionsleiste in einer Aktivität zu verbergen verwenden:

<activity 
     android:theme="@style/Theme.AppCompat.Light.NoActionBar" 
/> 
+0

Okay, aber wie Sie aus meinem Manifest oben sehen, ich bin das Thema für die zweite Aktivität und immer noch keine Bar – andrewb

+0

post den 'secondActivity-Code 'auch stellen Sie sicher, dass es erweitert' AppcompatActivity' – rafsanahmad007

Verwandte Themen