gpt4 book ai didi

android - 如何在android的操作栏中设置应用程序图标

转载 作者:行者123 更新时间:2023-11-29 01:14:11 25 4
gpt4 key购买 nike

我想在我的操作栏上设置我的应用程序图标请帮助我

我试过这个但没有创建:

    getSupportActionBar().setTitle("MukilFM");
getSupportActionBar().setIcon(R.drawable.fm);

最佳答案

只需为操作栏创建一个单独的 layout.xml 文件,并将其作为自定义操作栏包含在 main.xml 中,并将主要 Activity 的主题设置为 noTitle bar。 这是我的 custome_app_bar.xml

<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
app:theme="@style/AppTheme"
android:padding="5dp"
>
<ImageView
android:id="@+id/acton_bar_imageView"
android:background="@drawable/app_logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"/>

并包含在 main.xml 中就是这样....

    <include
android:id="@+id/app_bar"
layout="@layout/custome_app_bar"
/>

关于android - 如何在android的操作栏中设置应用程序图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40908011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com