-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Description
代码:
<ImageButton
android:id="@+id/left_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_test"
android:layout_toRightOf="@id/left_textview"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp" />生成的内容:
ImageButton imageButton4 = new ImageButton(ctx);
RelativeLayout.LayoutParams layoutParam4 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
imageButton4.setId(R.id.left_image2);
imageButton4.setBackgroundResource(R.drawable.selector_test);
layoutParam4.addRule(RelativeLayout.RIGHT_OF,R.id.left_textview);
layoutParam4.addRule(RelativeLayout.CENTER_VERTICAL,RelativeLayout.TRUE);
layoutParam4.leftMargin= (int)(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10,res.getDisplayMetrics())) ;
imageButton4.setLayoutParams(layoutParam4);
relativeLayout1.addView(imageButton4);这里 imageButton4.setBackgroundResource(R.drawable.selector_test); 把seulector资源刚在普通的图片资源了,这是不对的。
建议修复bug。
Metadata
Metadata
Assignees
Labels
No labels