I would like to add an unknown amount of progressbar to a linearlayout.
(Like Whatsapp Status, and Instagram Stories)
I can add progressbar to the linearlayout but the progressbar just shows max 7 progressbar.
My code so far:
while (i < 10){
i ++;
View child = getLayoutInflater().inflate(R.layout.stories_progress, null);
linearLayout.addView(child);
}
I would like to shrink the size of the progressbar programmatically, so when I have 2 progressbar, they fill the layout with 50%/50%, when 5, 10 or even 20 progressbar, they become smaller, all of them will be displayed on linearlayout I tried to get the current width of the linearlayout and divide by the number of progressbars, but the width of the linearlayout returns always 0;
My xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linear_layout_id"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
tools:context=".stories">
</LinearLayout>
My progressbar
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<ProgressBar
android:id="@+id/stories_progressBar_id"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ProgressBar>
</LinearLayout>