这里使用的是制作图像Button的法典。 我的所有县都将充满活力地建立起来。
//It is button which inherits from ImageView
ImageButton button = new ImageButton(this);
Drawable testPic = getResources().getDrawable(R.drawable.test_pic);
//button.setBackgroundColor(R.color.transparent_background);//transparent image button button background
//button.setImageDrawable( testPic );
button.setBackgroundDrawable(testPic);
//button.setMaxWidth(20);
button.setOnClickListener(mCorkyListener);
button.setTag(i);
//button.setId(i);
//Controls how the image should be resized or moved to match the size of this ImageView.
button.setScaleType( ScaleType.CENTER_INSIDE );
System.out.println("button with "+button.getMeasuredWidth());
System.out.println("button height "+button.getMeasuredHeight());
首先是我的系统。 排出<<>条码>,直线0和 but吨高0,但装置一看其大于一意。
LinearLayout pubLayout = (LinearLayout)findViewById( R.id.myFilesScrollerLayout);
pubLayout.addView( button );
<ScrollView
android:id="@+id/myFilesScroller"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
>
<LinearLayout
android:id="@+id/myFilesScrollerLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
So how to change my ImageButton size depending maybe on ScrollView size. Also how to show that button is pressed ?
感谢。