Ändern Sie den status bar color in Android
Baue ich ein Android-Anwendung, und jetzt möchte ich ändern die Statuszeile (oben auf dem Bildschirm, die anzeigen, WLAN-Bereich und Signale, Akku-status, etc), aber es funktioniert nicht.
Auf die Vorschau der XML-Datei zeigt es eine andere Farbe (der Farbton von orange, den ich nutzen möchte) für die bar, aber wenn ich die Anwendung ausführen, sowohl im emulator und auf meinem Handy die Farbe weiß bleibt.
Verstecke ich die action bar und legte ein graues Bild auf der Oberseite der app.
Dies ist die Vorschau in Android Studio die XML-Datei
- Und dies ist die emulation der Anwendung:
Dies ist mein colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="theme_color">#D8540D</color>
<color name="toolbar_title_color">#E66800</color>
<color name="grey">#d3d3d3</color>
<color name="maroon">#7f0000</color>
<color name="color_textual">#8D5020</color>
<color name="chef_bg_color">#F7F7F7</color>
<color name="line_color">#dddddd</color>
</resources>
- Und das ist meine styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">@color/theme_color</item>
<item name="android:navigationBarColor">@color/theme_color</item>
<item name="android:colorEdgeEffect">@color/theme_color</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Android-Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mvaguimaraes.bt">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainScreen"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".OrderDetails"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".PastOrderDetails"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
</manifest>
Gerade gebucht und das Android-Manifest!
Danke, kannst du auch nach dem code für die Aktivität?
Mögliche Duplikate von so ändern Sie den status bar color in android
InformationsquelleAutor Marcos Guimaraes | 2016-05-12
Du musst angemeldet sein, um einen Kommentar abzugeben.
In Ihnen manifest-Datei werden alle Aktivitäten von Ihnen angegebenen Thema als NoActionBar.
Aber in styles.xml innerhalb NoActionBar Thema haben Sie nicht Hinzugefügt, die folgende Zeile des Codes:
<item name="android:statusBarColor">@color/theme_color</item>
Oben einfügen Zeile code in der Art von NoActionBar Thema dann die Farbe der Statusleiste wird sich sicher ändern.
Aber ja, es wird funktionieren für api-level 21 und höher.
NoActionBar
Thema leitet sich die Attribute vonAppTheme
mit Punkt-notation, alsoandroid:statusBarColor
eingestellt ist und es keine Notwendigkeit gibt, fügen Sie diese Zeile.InformationsquelleAutor Random
In KitKat Statusleiste Farbe wird nicht geändert, aber Sie können sehen, es änderungen in Lollipop und Marshmallow.
In der "res/Werte/Farben"
hier nach kitkat, "colorPrimaryDark" wird angewandt für "Statusleiste" und "colourPrimary" wird für die Symbolleiste/actionbar automatisch.
kann dieser link hilft https://developer.android.com/training/material/theme.html
InformationsquelleAutor Yellappa
Können Sie ändern Sie Ihren status bar Farbe mit diesen paar Zeilen:
InformationsquelleAutor Vajani Kishan