Saboor880 9 Junior Poster

Hi! I am now using androidx libraries in my andriod application. But the problem which I am facing is that the Image view of androidx library does not show/display any image on android 5(i-e lollipop) real device. But if I run the app on emulator , then my imagview shows the loaded image on android 5/lollipop. I am pasting my code of imageview. Kindly guide me what i can do to solve it. Folloiwng is my xml for imageView

  <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/imv"
        android:layout_below="@id/ed_note"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_gravity="center_horizontal"
        android:usesCleartextTraffic="true"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:background="@drawable/imageview_border"
        >

    </androidx.appcompat.widget.AppCompatImageView>

Now I am pasting java code for loading image view from gallery

// code for opening gallery and picking image
 btn_uploadphoto.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);

               startActivityForResult(i,SELECT_FROM_GALLERY);
           }
       });

       // code of OnActivity result

        @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode==SELECT_FROM_GALLERY) {
            if (resultCode == RESULT_OK) {

                capturedImageUri = data.getData();
                if(capturedImageUri!=null){

                    Glide.with(this).load(capturedImageUri).into(iv);

                }

            }
        }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.