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.
– Pablo Almeida
Which folder is the image in? What type of drawable is (png, jpg, xml/svg, other)?
– ramaral
C: Users user Androidstudioprojects Meuapp app src main res drawable. Is jpg.
– J.Young
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.
– J.Young