title: How to set ImageButton size and when button is pressed show it on added image
body: <p>Here is the code i am using to create ImageButton. All my buttons will be created dynamically. </p>
  
  <pre><code>        //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());
  </code></pre>
  
  <p>First of all my System.out return <code>button with 0 and button height 0</code> but on device i see that it is bigger than i want, I put this button into Scrollview:</p>
  
  <pre><code>LinearLayout pubLayout = (LinearLayout)findViewById( R.id.myFilesScrollerLayout);
  
  pubLayout.addView( button );
  
  &lt;ScrollView
      android:id="@+id/myFilesScroller"
      android:layout_width="200dp"
      android:layout_height="match_parent"
      android:layout_alignParentBottom="true"
      android:layout_alignParentTop="true"
  
       &gt;
  
      &lt;LinearLayout
          android:id="@+id/myFilesScrollerLayout"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>So how to change my ImageButton size depending maybe on ScrollView size. Also how to show that button is pressed ?</p>
  
  <p>Thanks.</p>