Image inside a Scrollview is blank on one device but usually appears on another

Asked

Viewed 106 times

1

I have a Alertdialog whose content is a Scrollview with an image and a button inside. Scrollview works (I can "scroll" the bar), but the image does not appear (it is empty), although the button appears (when scrolling to the end). Already on a friend’s cell phone, the image appears. I think the only difference from his phone to mine is the Android version: his is 6.0 and my 4 something. Follow the XML code of the layout that I inflate in Alertdialog:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/imagem_teste" />

<Button
    android:id="@+id/bt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:backgroundTint="@color/viewfinder_laser"
    android:text="Entendi"
    android:textAppearance="@style/TextAppearance.AppCompat.Large.Inverse" />


</LinearLayout>

And the code of the button that creates and displays the dialog:

btnSobre.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LayoutInflater li = getLayoutInflater();
View view = li.inflate(R.layout.alerta, null);

                view.findViewById(R.id.bt).setOnClickListener(new View.OnClickListener() {
                    public void onClick(View arg0) {
                        alerta.dismiss();
                    }
                });

                AlertDialog.Builder builder = new AlertDialog.Builder(TelaInicial.this);
                builder.setTitle("Sobre...");
                builder.setView(view);
                alerta = builder.create();
                alerta.show();

            }
        }
);

Would anyone know to tell me why the image did not appear?

  • Already tested in emulator? You can test in different versions of Android and see if the problem is the same version.

  • Which folder is the image in? What type of drawable is (png, jpg, xml/svg, other)?

  • C: Users user Androidstudioprojects Meuapp app src main res drawable. Is jpg.

  • Not Pablo, not tested, but it’s a good tip. However when I open the emulator my pc gets a little slow, especially if I have more open. Only android studio runs well of good, so do not use emulator.

2 answers

1


I was able to fix it. I set the hardware acceleration in Manifest to false. android:hardwareAccelerated="false"

0

Tries to reattach the image by programming line

          AlertDialog.Builder builder = new AlertDialog.Builder(TelaInicial.this);
            builder.setTitle("Sobre...");
            builder.setView(view);  //a proxima linha seta a imagem na view
            ((ImageView) view.findViewById(R.id.YOUR_ID_IMAGEVIEW)).setImageResource(R.drawable.yourImage);
            alerta = builder.create();
            alerta.show();
  • It didn’t work, Caio. I honestly don’t know what else to do. On my friend’s phone is perfect and mine is blank, Although appear scroll and boot at the end of scroll view.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.