在操作栏上的显示方式标志栏上、标志、操作、方式

2023-09-12 23:42:14 作者:城南巷

我想告诉标志我的行动吧活动,我用低于code的清单:

i want to show logo on my action bar activity and i used below code in manifest:

        <activity
            android:name=".CompanyActivity"
            android:icon="@drawable/ic_launcher"
            android:logo="@drawable/ic_launcher"
            android:label="@string/title"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
        </activity>

和同样在java中使用都低于codeS,在活动的onCreate方法:

and also use both below codes in java, in onCreate method of activity:

getSupportActionBar().setIcon(R.drawable.ic_launcher);

ActionBar ab = getSupportActionBar();
ab.setLogo(R.drawable.ic_launcher);

但标志操作栏不显示。我能做什么? TNX很多

but logo not displayed in action bar. what can i do? tnx a lot

推荐答案

棒棒糖不显示标志默认这样设置:

Lollipop doesn't show logo by default so set:

 getSupportActionBar().setDisplayShowHomeEnabled(true);
 getSupportActionBar().setLogo(R.drawable.ic_launcher);
 getSupportActionBar().setDisplayUseLogoEnabled(true);