문제

I'd like to add an icon of my application to screen's title bar. what shold be icon size? And I'd like to remove the application name form this title bar and display only the icon. How it can be done? Thanks, Eyal.

도움이 되었습니까?

해결책

It's possible to set your own custom title layout, however the order of execution matters. You must do things in this order:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.my_layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_title);

Additionally, you may need to increase the size of the title; if you don't, then the bottom of your custom layout may just be covered up by your Activity. You can change the size by adding a theme that specifies the title's size. This would go into a values XML file:

<resources>
    <style name="LargeTitleTheme">
         <item name="android:windowTitleSize">40dip</item>
    </style>
</resources>

Then you'd need to set the theme for your Activity (or Application, if you want the entire application to have this custom title bar) in AndroidManifest.xml:

<activity android:name=".MyCustomTitleActivity" android:theme="@style/LargeTitleTheme" />

Example of custom title bar

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top