我正在改变我的按钮样式:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)btBroadcast.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
btBroadcast.setLayoutParams(params);
如何在上面添加这四条规则?
android:layout_marginRight="16dp"
android:scaleType="centerInside"
android:layout_width="20"
android:layout_height="20"
答案 0 :(得分:1)
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)btBroadcast.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
params.height = 10;
params.width = 20;
params.rightMargin = 10;
btBroadcast.setScaleType(ImageView.ScaleType.CENTER);
btBroadcast.setBackgroundResource(R.drawable.image);
btBroadcast.requestLayout();