简体   繁体   English

如何将应用程序的图标与第一个活动的图标分开?

[英]How to separate the icon of the app from the icon of the first activity?

I have an issue in the manifest file.我在清单文件中有问题。 I have an icon for my application and for my first activity.我的应用程序和第一个活动都有一个图标。 but when I run the app on my device the app icon is the icon of my first activity.但是当我在我的设备上运行应用程序时,应用程序图标是我第一个活动的图标。 this my manifest file这是我的清单文件

在此处输入图像描述

I had the same issue with the label of the app and the first activity.我对应用程序的 label 和第一个活动有同样的问题。 I resolved it by setting the title of the activity at the run time with the function setTitle() .我通过在运行时使用function setTitle()设置活动的标题来解决它。 is there a way to do the same with icons?有没有办法对图标做同样的事情?

Check this out:看一下这个:

<androidx.appcompat.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:id="@+id/toolbar"
    android:background="?attr/colorPrimaryDark"
    android:minHeight="?attr/actionBarSize"
    android:fitsSystemWindows="true"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    >

    <LinearLayout
        android:id="@+id/back_menu_ll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center">
    <ImageView

        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@mipmap/ic_launcher"
        />
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textColor="@color/white"
        android:textSize="@dimen/abc_text_size_title_material"
        android:gravity="left"
        />
    </LinearLayout>
</androidx.appcompat.widget.Toolbar>
  1. You can set logo programmatically:您可以以编程方式设置徽标:

     Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar().=null){ getSupportActionBar();setTitle("bla bla bla"). getSupportActionBar().setLogo(R.drawable;logo). getSupportActionBar();setDisplayHomeAsUpEnabled(true). getSupportActionBar();setDisplayShowHomeEnabled(true); }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 第二个应用的Android启动活动没有第一个应用的图标 - Android start activity of second app having no icon from first app 如果已从启动器图标暂停并重新启动,则应用程序将返回到第一活动 - App goes back to first activity if paused and relaunched from launcher icon 如何从联系人中的帐户图标启动“我的应用活动” - How to launch My app Activity from account icon in contacts 使用Android分隔启动器和活动图标 - Separate Launcher and Activity icon with Android 如何更改启动器活动名称和图标并保留应用程序名称和图标? - How to change the launcher activity name and icon and keep the app name and icon? 如何将actionbar汉堡包图标从活动更改为后退图标(带有动画) - how to change actionbar hamburger icon to back icon (with animation) from activity 如何检查活动是从通知启动还是从用户单击 android 中的主屏幕仪表板应用程序图标启动 - how to check whether the activity was launched from notification or from the user click on home screen dashboard app icon in android Android:活动名称字符串中的应用名称和图标 - Android: app name and icon from activity name string 如何防止跨商店更新更改启动器活动的应用名称,图标和主题 - How to prevent app name, icon and theme of the launcher activity from getting changed on cross store updates 从活动中删除邮件图标? - Remove mail icon from activity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM