【问题标题】:Icon doesn't show on app android studio应用程序android studio上不显示图标
【发布时间】:2018-01-06 18:50:00
【问题描述】:

我的应用有问题。
我知道有类似的问题,但他们没有帮助我。
我的应用图标不可见。
我通过mipmap -> NEW -> Image Asset添加了一个新图标。
但它没有显示。

这是我的清单文件:

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

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/my_car"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/round_car"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".controller.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".controller.AddCarActivity"
            android:label="Add_Car" />
        <activity
            android:name=".controller.AddClientActivity"
            android:label="Add Client" />
        <activity
            android:name=".controller.AddCarModelActivity"
            android:label="Add Car Model" />
        <activity
            android:name=".controller.ShowCarListActivity"
            android:label="Show Car List" />
        <activity
            android:name=".controller.ShowCarModelListActivity"
            android:label="Show Car Model List" />
        <activity
            android:name=".controller.ShowBranchListActivity"
            android:label="Show Branch List" />
        <activity
            android:name=".controller.ShowClientListActivity"
            android:label="Show Client List" />
        <activity
            android:name=".controller.AddBranchActivity"
            android:label="Add Branch"></activity>
    </application>

</manifest>

这是我使用的风格:

<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

这是我的 XML 布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.owner.takeandgo.controller.MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <Button
            android:id="@+id/AddCarButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Add Car" />

        <Button
            android:id="@+id/AddBranchButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Add Branch" />

        <Button
            android:id="@+id/AddCarModelButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Add Car Model" />

        <Button
            android:id="@+id/AddClientButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Add Client" />

        <Button
            android:id="@+id/showCarListButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="Show Car List" />

        <Button
            android:id="@+id/showBranchListButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Show Branch List" />

        <Button
            android:id="@+id/showCarModelListButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Show Car Model List" />

        <Button
            android:id="@+id/showClientListButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Show Client List" />


   </LinearLayout>
</ScrollView>

这是Android Emulator的图片,只有文字没有图标:

【问题讨论】:

  • 哪里没有显示图标?
  • 我加了一张图片让你看看
  • 你在哪里使用图标?
  • 什么意思?你可以在清单文件中看到
  • 在设置图标的地方添加代码

标签: android android-studio


【解决方案1】:

现在可以了。 我将这些行添加到主要活动中:

getSupportActionBar().setLogo(R.mipmap.my_car);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多