【问题标题】:Activity icon for style Theme.Holo.Light.Dialog.MinWidth样式 Theme.Holo.Light.Dialog.MinWidth 的活动图标
【发布时间】:2014-03-29 15:38:33
【问题描述】:

这是我活动的风格

<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>

它会根据需要正确显示为非全屏对话框。 我还想在活动标题的左侧显示一个图标,但我不知道怎么做。 提前致谢。

PS minSdkVersion 13

【问题讨论】:

    标签: android dialog styles android-actionbar icons


    【解决方案1】:

    当您使用该样式时,Android 将使用不包含 ImageView 图标的 layout。但是,您可以使用显示标题的TextView 调用TextView.setCompoundDrawablesWithIntrinsicBounds 以显示您的图标。 Otherwise you might look into an implementation like this.

    实施:

        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);
        }
    

    结果

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-15
      • 2014-11-13
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多