I tried many ways to add an image to a Progress Dialog
Please Help me.
Asked
Active
Viewed 1,190 times
-1

Phantômaxx
- 37,901
- 21
- 84
- 115

Chathura Liyanage
- 212
- 2
- 11
-
1With inflate custom view. – Piyush Nov 19 '18 at 12:13
-
go for this link, you will get help https://stackoverflow.com/questions/12115350/android-custom-progressdialog-with-message – Rishav Singla Nov 19 '18 at 12:25
2 Answers
1
Try This Code
Dialog dialog = new Dialog(MainActivity.this);
dialog.setContentView(R.layout.custom_dialog_lay);
//dialog.setTitle("Progress");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Loading... ");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.android);
custom_dialog_lay.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#FFF"
/>
<ImageView android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/sms_ic"
/>

Sniffer
- 1,495
- 2
- 14
- 30
-
Yes..!! it's Worked for me..!! but Could you please tell me how to remove title of the dialog..? – Chathura Liyanage Nov 19 '18 at 12:51
-
1
-
when comment this line Title not showing but it's space still there..!! how to remove it..! – Chathura Liyanage Nov 20 '18 at 02:59
-
-
@Chathura you can try Picasso or Glide library Check this [answer](https://stackoverflow.com/a/30424748/5978440) – Sniffer Nov 20 '18 at 04:55
1
Insert a layout which will hold the progressbar, text and imageview inside your layout like it is done below:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recipe_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.android.bakingapp.MainActivity"/>
<LinearLayout
android:id="@+id/dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_gravity="center"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_gravity="center"
android:textColor="@color/colorAccent"
android:layout_margin="20dp"
android:textSize="30sp"/>
<TextView
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_gravity="center"
android:textColor="@color/colorAccent"
android:text="Loading..."
android:textSize="20sp"
android:layout_margin="20dp"/>
<ImageView.../>
</LinearLayout>
</FrameLayout>

Show Young Soyinka
- 544
- 3
- 14