0

for some reason - when running my application - while processing is occurred (server request)- i see my custom spinner(ok) and also a bar...i can not figure out why.. it is not happen in all devices...

enter image description here

this is my code:

 public ServerRequests(Context context) {
    progressDialog = new Dialog(context);
    progressDialog.setCancelable(false);
    progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    progressDialog.setContentView(R.layout.progress_spinner);

}

progress_spinner.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center">

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminateDrawable="@drawable/progress"/>

</RelativeLayout>

progress.xml

<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="5"
    android:toDegrees="1080">

    <shape
        android:shape="ring"
        android:innerRadiusRatio="3"
        android:thicknessRatio="8"
        android:useLevel="false">

        <size
            android:height="48dip"
            android:width="48dip" />

        <gradient
            android:endColor="#cdcd00"
            android:startColor="@android:color/transparent"
            android:type="sweep"
            android:angle="0"
            android:useLevel="false" />
    </shape>

</rotate>
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
Hilit
  • 65
  • 1
  • 8
  • You have an indeterminate drawable on your progress bar but you didn't set `android:indeterminate="true"`... Is the progress bar indeterminate or not? – kris larson Jan 04 '16 at 16:04
  • The blue bar shouldn't be there..this is my problem..only the yellow spinner should. – Hilit Jan 04 '16 at 17:03
  • Try setting `android:indeterminate="true"` on the progress bar and see if that fixes the problem. – kris larson Jan 04 '16 at 17:07
  • thanks..i have set this but it still wrong :( – Hilit Jan 04 '16 at 17:12
  • Other things you can try are `android:indeterminateOnly="true"` and `android:progressDrawable="@null"` – kris larson Jan 04 '16 at 17:15
  • not working...the funny thing is that for example- it doesn't happen at devices: s1 or note5 or lg..but it is wrong at s2....anyway in Gennymotion emulator i see it all wrong.. – Hilit Jan 04 '16 at 17:22
  • i think that this value `android:thicknessRatio="8"` is unproportional to the previous one. Make it smaller and run first on devices with BUG ;-) – piotrek1543 Jan 04 '16 at 18:53

1 Answers1

2

This bar is actually the dialog title bar divider. It does not exists on lollipop or later but it do exists on ics to kk

So all what you need is to set it to transparent like this:

progressDialog = new Dialog(context);
progressDialog.setCancelable(false);
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
progressDialog.setContentView(R.layout.progress_spinner);
if (android.os.Build.VERSION.SDK_INT <= 19 && android.os.Build.VERSION.SDK_INT >= 14) {
    int dividerId = progressDialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
    View divider = progressDialog.findViewById(dividerId);
    divider.setBackgroundColor(Color.TRANSPARENT);
}

read more: How to change alert dialog header divider color android

Community
  • 1
  • 1
Naheel
  • 497
  • 3
  • 13