문제

This is the style for my activity

<style name="AppTheme" parent="android:Theme.Holo.Light.Dialog.MinWidth">
  <item name="android:windowTitleStyle">@android:style/TextAppearance.Holo.Large</item>
  <item name="android:windowCloseOnTouchOutside">true</item>
</style>

and it is correctly displayed as a not full screen dialog, as desired. I'd like to display an icon also to the left of the activity title but I cannot figure out how. Thanks in advance.

PS minSdkVersion 13

도움이 되었습니까?

해결책

When you use that style, Android will use a layout that doesn't include an ImageView for an icon. However, you can call TextView.setCompoundDrawablesWithIntrinsicBounds using the TextView that displays the title to show your icon. Otherwise you might look into an implementation like this.

Implementation:

    final TextView title = (TextView) findViewById(android.R.id.title);
    if (title != null) {
        title.setPadding(30, 0, 0, 0);
        title.setCompoundDrawablePadding(30);
        title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.your_icon, 0, 0, 0);
    }

Results

Example

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