View customNav = LayoutInflater.from(this).inflate(R.layout.activity_custom_layout, null);
actionBar.setCustomView(customNav);
actionBar.setDisplayShowCustomEnabled(true);
final Context context1 = this;
ImageButton ibItem1 = (ImageButton) customNav.findViewById(R.id.refresh);
ibItem1.setPadding(280, 0, 0, 0);
ibItem1.setVisibility(View.INVISIBLE);
ibItem1.setOnClickListener(new View.OnClickListener()
{ @Override public void onClick(View view) { } });
我添加自定义视图与图像按钮,机器人操作栏,图像按钮的大小小,所以需要改变操作栏的大小进行适当的图像大小?
I have added custom view with image button to android action bar,image button size is small,so need to change the size of action bar for proper image size?
您可以改变动作条的THW宽度和高度动态...
you can change thw width and height of the actionbar dynamically...
试试这个样本...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View contentView = getLayoutInflater().inflate(R.layout.test_layout, null);
setContentView(contentView);
LinearLayout layout = (LinearLayout) contentView.getParent()
.getParent();
View view = layout.getChildAt(0);
ViewGroup actionBarView = (ViewGroup) view;
LinearLayout.LayoutParams layoutParams = (android.widget.LinearLayout.LayoutParams) actionBarView
.getLayoutParams();
layoutParams.width = 200;
layoutParams.gravity = Gravity.CENTER;
actionBarView.setLayoutParams(layoutParams);
}
上一篇:如何通过标签传递数据?标签、数据
下一篇:收到MMS通知通知、MMS