Kaustubh
Kaustubh

Reputation: 653

Android : Hide corners of custom progressbar

I am trying to design a custom progressbar but not able to hide its corners. I am trying to highlight the white patches near the corners, highlighted by black circles.

enter image description here

I tried the following code, but it is not working

customProgressbar.getWindow().setBackgroundDrawable(new ColorDrawable(0));

here is my drawable file

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="@color/pale_orange" />
<stroke android:color="@android:color/transparent"/>
<corners
    android:bottomLeftRadius="10dp"
    android:bottomRightRadius="10dp"
    android:topLeftRadius="10dp"
    android:topRightRadius="10dp" />

<padding
    android:bottom="3dp"
    android:left="3dp"
    android:right="3dp"
    android:top="3dp" />
</shape>

Here is my XML layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" >

<RelativeLayout
    android:background="@drawable/progressbar_background"
    android:layout_centerInParent="true"
    android:layout_width="100dp"
    android:layout_height="100dp" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="10dp"
        android:text="Loading.."
        android:textColor="@color/white" />

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

</RelativeLayout>

Please help in getting a solution. Many thanks!

Upvotes: 0

Views: 187

Answers (2)

FeleMed
FeleMed

Reputation: 621

I think you should replace this line in your relative layout

android:background="@color/white"
for
android:background="@android:color/transparent"

Upvotes: 0

Rod_Algonquin
Rod_Algonquin

Reputation: 26198

problem:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" >

As you could see the background color of your parent RelativeLayout is white thus giving you white background as you could from your sample image above.

solution:

set the background color of RelativeLayout to transparent to remove the white background

android:background="@android:color/transparent"

Upvotes: 1

Related Questions