I want to create a horizontal list of images which user can add (and delete) dynamically, except the first one (it works like add image button). User will click on that first one to add more pictures to the left of it. As shown below I create a horizontal scroll and linear layout which initially has one NetworkImageView, which is the image adder button.

The xml has:

```
...
        <HorizontalScrollView
            android:id="@+id/horizontal_scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:id="@+id/linear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <com.android.volley.toolbox.NetworkImageView
                    android:layout_width="100dp"
                    android:layout_height="100dp"
                    android:id="@+id/imageViewAdd"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"
                    android:background="@color/colorAccent"
                    android:contentDescription="@string/description" />

            </LinearLayout>

        </HorizontalScrollView>
...

```

Then in the code, as the user clicks on that NetworkImageView, I want to add other ones in front of it one by one.

```
...
// On create code
layout = (LinearLayout) findViewById(R.id.linear);
        imageViewAdd = (NetworkImageView)findViewById(R.id.imageViewAdd);
        ImageLoader imageLoader = CustomVolleyRequest.getInstance(this.getApplicationContext())
                .getImageLoader();
        imageLoader.get(Config.IMAGE_PATH_URL, ImageLoader.getImageListener(imageViewAdd,
                R.drawable.image, android.R.drawable
                        .ic_menu_camera));
        imageViewAdd.setImageUrl(Config.IMAGE_PATH_URL, imageLoader);
        imageViewAdd.setOnClickListener(this);
        totalImageCount = 0;
...
// Create and add new image view
NetworkImageView newView = new NetworkImageView(this);
        newView.setId(id);
        newView.setPadding(2, 2, 2, 2);
    newView.setScaleType(ImageView.ScaleType.FIT_XY);
    layout.addView(newView, id);

    ImageLoader imageLoader = CustomVolleyRequest.getInstance(this.getApplicationContext())
            .getImageLoader();
    imageLoader.get(Config.IMAGE_PATH_URL, ImageLoader.getImageListener(newView,
            R.drawable.image, android.R.drawable
                    .ic_dialog_alert));
    newView.setImageUrl(Config.IMAGE_PATH_URL, imageLoader);
    newView.requestLayout();
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            (int) getResources().getDimension(R.dimen.imageview_height), // 100 dp each
            (int)getResources().getDimension(R.dimen.imageview_width));
    newView.setLayoutParams(layoutParams);
...

```

Later in the code, when I actually want to set an image path to that, I read the width and height as follows:

```
int targetW = newView.getWidth();
int targetH = newView.getHeight();

```

Both of which returns 0. I have seen many solutions in SO but none of them worked for me (in my code you may see the residues of different approaches, which I have been trying for the last 3 hours!).

Any help is appreciated!