How To Make An Progressbar Touch Bottom Screen Border In Android
I am having a similar problem as mentioned in here Here is my xml layout :
protectedvoidonLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
progressBar.setY(layout.getY() + layout.getHeight() - progressBar.getHeight() / 2);
}
Works like a charm and for all screen sizes.
Solution 2:
I found a work around.I am basically adding a layout_marginBottom="-4dp" to my ProgressBar and wrapped it inside a RelativeLayout and aligned it to the bottom of the parent view.This changes may break your app in the future.For a better solution design a custom progress bar with your own custom drawable which you can align correctly and occupies less canvas space compared to the progressBarStyleHorizontal.
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentBottom="true"><ImageButtonandroid:id="@+id/imageButton”
android:layout_width="40dip"
android:layout_height="match_parent"android:background="@android:color/transparent"android:contentDescription="@string/descrp"android:scaleType="center"android:src="@drawable/some_drawable”
android:visibility="visible" /><TextViewandroid:id="@+id/textview”
android:layout_width="wrap_content"
android:layout_height="wrap_content"android:layout_marginRight="10dip"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:textColor="#FFFFFF"android:textStyle="bold" />
//changes
<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><ProgressBarandroid:id="@+id/some_other_id"style="?android:attr/progressBarStyleHorizontal"android:layout_width="match_parent"android:layout_height="10dp"android:layout_alignParentBottom="true"android:layout_marginBottom="-4dp" /></RelativeLayout></RelativeLayout>
Solution 3:
Just add the following attributes inside ProgressBar
android:minHeight="4dp"// or whatever height you want
android:maxHeight="4dp"// or whatever height you want
Complete code:
<ProgressBar
android:id="@+id/snackbar_progress_crop"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:indeterminateOnly="false"
android:minHeight="4dp"
android:maxHeight="4dp"
/>
Post a Comment for "How To Make An Progressbar Touch Bottom Screen Border In Android"