title: showing image as small size in android
body: <p>My application need to show images from a host url. I am adding the image to the inner layout from class file. But I'm not able to reduce the image size and as you can see it is occupying the complete screen.</p>
  
  <p><img src="https://i.stack.imgur.com/Ru9vp.png" alt="Screen Out put"></p>
  
  <pre><code>  import beans.MenuItem;
      import android.app.Activity;
      import android.app.ActionBar.LayoutParams;
      import android.content.Context;
      import android.net.ConnectivityManager;
      import android.net.NetworkInfo;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.Menu;
      import android.view.View;
      import android.widget.Button;
      import android.widget.LinearLayout;
      import android.widget.TextView;
           public class ImageLoading extends Activity {
                  public static final String PHOTOS_BASE_URL = 
                          "http://services.hanselandpetal.com/photos/";
                  final  JSONObject cartinproduct= new JSONObject();
                  @Override
                  protected void onCreate(Bundle icicle) {
                      setContentView(R.layout.imageloding);
                      super.onCreate(icicle);
                  Button display=(Button) findViewById(R.id.button1);
                  display.setOnClickListener(new View.OnClickListener() {
  
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
                          updateDisplay();
                      }
                  });
                       }
                      protected boolean isOnline() {
                      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                      NetworkInfo netInfo = cm.getActiveNetworkInfo();
                      if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
                          return true;
                      } else {
                          return false;
                      }
                  }
                  @Override
                  public boolean onCreateOptionsMenu(Menu menu) {
                      getMenuInflater().inflate(R.menu.main, menu);
                      return true;
                  }
                  protected void updateDisplay() {
                      Log.v("updateDisplay", "Started");
                      setContentView(R.layout.imageloding);
                      final LinearLayout lm = (LinearLayout) findViewById(R.id.linearMain);
                      final MenuController Controller =  (MenuController) getApplicationContext();
                      MenuItem MenuObject = new MenuItem(); 
                      Log.v("loop", "Started");
                          for(int i=0;i&lt;3;i++)
                          {
                          MenuObject.setMenu_name("Product "+i);
                              Controller.setProducts(MenuObject);
                          }
                          //Product arraylist size
                          int ProductsSize = Controller.getProductsArraylistSize();
  
                          // create the layout params that will be used to define how your
                          // button will be displayed
                          LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                          LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                          Log.v("for loop", "Started");
                          for(int j=0;j&lt; ProductsSize;j++)
                          {   
                              // Get probuct data from product data arraylist
                              String pName = Controller.getProducts(j).getMenu_name();
                                  // Create LinearLayout to view elemnts
                              LinearLayout ll = new LinearLayout(this);
                              ll.setOrientation(LinearLayout.HORIZONTAL);
                              Log.v("inner loop", "Started");
                              com.example.testapp.LoaderImageView image=new LoaderImageView(this, "http://developer.android.com/images/dialog_buttons.png");
                              image.setImageDrawable("http://developer.android.com/images/MENU_MNU105.jpg");
                              ll.addView(image);
                              TextView product = new TextView(this);
                              product.setText(" "+pName+"    ");
                              ll.addView(product);
                                          lm.addView(ll);
                  }
                  }
          }
  </code></pre>
  
  <p>Layout code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:hint="@string/display" /&gt;
  
       &lt;LinearLayout
          android:id="@+id/linearMain"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
      &lt;/LinearLayout&gt;
  
       &lt;ProgressBar
           android:id="@+id/progressBar1"
           style="?android:attr/progressBarStyleLarge"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>