How to add logo with app tag in android studio

<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:logo="@drawable/logo"
    android:theme="@style/AppTheme" >

This is my androidmanifest.xml

and in mainactivity.java I use these lines to display the logo in the action bar.

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.logo);

after using these two lines in the .java file, my logo is displayed, but the application shortcut is gone .... is they any way that the logo and application label will be displayed on the action bar after apk compilation.

+4
source share
2 answers

You do not need two lines in mainactivity.java, you need to select a theme using the ActionBar:

From res> layout> activity_main.xml (or whatever the layout name of your activity): on the Design tab, change the theme to "Holo.Light.DarkActionBar", for example.

AndroidManifest.xml ( ):

android:theme="@style/AppTheme"

"AppTheme" res > values > styles.xml :

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

, <application>:

<application
  android:logo="@drawable/logo"
  android:label="@string/app_name"
  android:theme="@style/AppTheme"
...
+2

.

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
</activity>
0

Source: https://habr.com/ru/post/1584297/


All Articles