WhatsApp Status like View: Android
5 min readAug 24, 2020
Let’s create a status activity like WhatsApp using RxJava.
First of all, I will create some extension functions that I am going to use in this post later.
fun ImageView.loadImage(imageUrl:String) {
val req = Glide.with(this)
.load(imageUrl)
.into(this)
}fun View.show() {
if (this.visibility != View.VISIBLE)
this.visibility = View.VISIBLE
}fun View.gone() {
if (this.visibility != View.GONE)
this.visibility = View.GONE
}fun Context.getScreenWidth(): Int {
val metrics = this.resources.displayMetrics
return metrics.widthPixels
}fun Context.convertDpToPixel(dp: Float): Float {
val resources = this.resources
val metrics = resources.displayMetrics
return dp * (metrics.densityDpi / 160f)
}
Now let’s create XML for the activity whatsapp_status_activity.
We are not bothered about the exact layout; it can be customized at any time. It's just for testing.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"><LinearLayout
android:id="@+id/ll_progress_bar"…