In my app, I select photos from gallery and insert them inside of LinearLayout
programmatically, so I did this :
<LinearLayout
android:orientation="horizontal"
android:id="@+id/linearImages"
android:layout_width="wrap_content"
android:layout_height="150dp">
<Button
android:layout_gravity="center"
android:id="@+id/add_btn"
android:gravity="center"
android:drawableLeft="@drawable/add_icon"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
And i'm set a tag to which photo that I'm putting :
public void AddNewImages(Context context,Bitmap bitmap){
ImageView img = new ImageView(context);
img.setScaleType(ImageView.ScaleType.FIT_XY);
img.setImageBitmap(bitmap);
img.setTag(tagCount);
linearImages.addView(img);
bitmapArray.add(bitmap);
tagCount++;
}
And I want to remove a Image by tapping, as I said before, the Images are added programmatically, so I need something to remove images one by one without have a static Image position.