0

A have an Activity (minSDK for my app = 14) to which the @android:style/Theme.Holo.Dialog Theme is applied. I need to set an icon, so I used

        this.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    this.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
            R.drawable.share);

I guess the icon is set (because the title moved to the right) but for some reason it is not visible as if it was transparent:

enter image description here

I can't find any logical explanation for this behavior. Any ideas?

P.S. no, my drawable is not the same color as the window's background

4

2 回答 2

1

如果我没记错的话,你必须Dialog在调用show它后将你的图标资源设置为自定义。

dialog.show();
dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.share);

为什么它会起作用而不是其他方式仍然是一个谜:)

于 2013-11-09T17:21:03.353 回答
0

这是命令:

1)this.requestWindowFeature(Window.FEATURE_LEFT_ICON);

2)this.setContentView(R.layout.xxx);

如果是对话框 ( dialog.show();)

3)this.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.share);

于 2017-03-02T19:34:43.283 回答