[英]How to set View to ActionBar icon? not by drawable
I'm trying to use CircleImageView as ActionBar icon (like chatting activity in WhatsApp). 我正在尝试将CircleImageView用作ActionBar图标(例如WhatsApp中的聊天活动)。 I've tried this approach :
我已经尝试过这种方法 :
CircleImageView actionBarIcon_Profile = new CircleImageView(this);
actionBarIcon_Profile.setImageDrawable(getResources().getDrawable(R.drawable.my_picture));
actionBarIcon_Profile.setLayoutParams(new LayoutParams(48, 48));
actionBarIcon_Profile.setId(R.id.actionBarIcon_Profile);
getActionBar().setIcon(R.id.actionBarIcon_Profile);
ids.xml: ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="actionBarIcon_Profile"/>
</resources>
It seems like ActionBar setIcon() only accepts drawables as input. 似乎ActionBar setIcon()仅接受可绘制对象作为输入。 I could have setup a circular shape xml and put it in my drawable folder , but even that I have to change the background of that xml file to fit my need.
我可以设置一个圆形的xml并将其放在我的drawable文件夹中 ,但是即使如此,我也必须更改该xml文件的背景以适合我的需要。 Any suggestions?
有什么建议么?
link - http://javatechig.com/android/actionbar-with-custom-view-example-in-android 链接-http://javatechig.com/android/actionbar-with-custom-view-example-in-android
see if this link helps you 查看此链接是否对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.