I want to add initial padding to progress bar, but that would be dynamic, as i am retrieving that value for initial padding from local database.
I have set progress bar's background with layer-list xml file.
`
<corners android:radius="7dip" />
<gradient
android:startColor="@color/background_start"
android:centerColor="@color/background_center"
android:centerY="0.75"
android:endColor="@color/background_end"
android:angle="270" />
<stroke
android:color="@color/stroke"
android:width="0.5dip"/>
</shape>
<corners android:radius="7dip" /> <gradient android:startColor="@color/secondory_progress_start" android:centerColor="@color/secondory_progress_center" android:centerY="0.75" android:endColor="@color/secondory_progress_end" android:angle="270" /> <stroke android:color="@color/stroke" android:width="0.5dip"/> </shape> </clip>
<corners
android:radius="7dip" />
<padding android:left="360dip"
android:right="50dip"/>
<gradient
android:startColor="@color/default_progress_start"
android:centerColor="@color/default_progress_center"
android:centerY="0.75"
android:endColor="@color/default_progress_end"
android:angle="270"
/>
<stroke
android:color="@color/stroke"
android:width="0.5dip"/>
</shape>
</clip>
And in java code, i am referencing xml file, like this:
layerDrawable = (LayerDrawable)progressBar.getProgressDrawable();
and retrieving simple progress child like this:
Drawable drawable = layerDrawable.getDrawable(layerDrawable.getId(2));
as it is on 2nd level of xml file.
And i set max value and progress value to progress bar. Now i want to add some left padding to progressbar's progress value. which i tried like this using setBounds method:
`Rect rect = new Rect();
rect = drawable.getBounds();
rect.left = drawable.getBounds().left + getPaddingForFirstPeriod() + 300; rect.right = rect.left + (int) 50; drawable.setBounds(rect);`
But it's not taking any effect on progressbar's primary progress value, and apart from this there is no padding method available for it.
Please help
Does old kind
View.setPadding(l,t,r,b)
not help any more?