1

I am displaying a ProgressBar in Android, as seen below:

alt text

but there is a white border around the progress bar. What if I dont want to display any border?

i.e., only the progress bar circle and text should be shown in the progress bar dialog.

How do I display the progress bar as shown below? (How do I display a progress dialog as Searching in the below image:)

alt text

Update: I failed to find a solution for this, but I think there should be some trick to display a progress bar dialog in this way. I mean to say there should be a way by extending some styles in styles.xml. Please anybody focus on this question and help me to display such dialog.

JDJ
  • 4,298
  • 3
  • 25
  • 44
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • Can you give a direction ? do you know whatare the stles that are used in this dialog ? most likly the style will be defined in the ProgressDialog class or the one that it inhertis from.Once you know you can smple go the the stles and attr xmls and check for the attribue that you want to override. – codeScriber Oct 15 '10 at 11:09
  • oh almost forgot: 1. if you need the code i have it on my Pc though it is avialable through gitweb... 2. i would take a look on the code of the widget itself, most chnaces it's just using some drawble that you can take and use in your own widget like TripAdvisor application does. 3. last but no least ;-) try to use android:background="transparent" – codeScriber Oct 15 '10 at 11:31
  • you can this link https://stackoverflow.com/questions/3225889 ,you could write your want base this link,i hope this can help you – pengwang Oct 17 '10 at 11:08

2 Answers2

2

After some experiments I got to the following:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="my_style" parent="@android:style/Theme.Dialog" >
        <item name="android:windowBackground">@null</item>
    </style>
</resources>

If I use this theme as a style for an Activity I get no frame. If you use this with the Dialog constructor: Dialog(context, theme) you get no frame.

JDJ
  • 4,298
  • 3
  • 25
  • 44
codeScriber
  • 4,582
  • 7
  • 38
  • 62
1

do you still need ideas for this? I implemented the same thing in my app, but not as a dialog, I had two layouts that overlap each other. I then flip between the two layouts by setting the visibility .setVisibility(). As for the actual progress bar itself, I use this:

EDIT: Here's my whole XML file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/background"> 
     <RelativeLayout android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:id="@+id/search_header" android:background="@drawable/header">
           <!-- Some things I need for the header (title, etc) -->
     </RelativeLayout>  
    <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:id="@+id/spinner_layout" android:layout_below="@+id/search_header" 
     android:layout_centerHorizontal="true" android:layout_centerVertical="true">
     <ProgressBar android:id="@+id/title_progress_bar"
   style="?android:attr/progressBarStyleSmallTitle"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignParentRight="true"
   android:layout_centerVertical="true"
   android:visibility="visible"
   android:indeterminateOnly="true"/>
  <TextView android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:id="@+id/loading_label" android:text="Loading..." 
   android:layout_gravity="center_vertical" android:layout_marginLeft="5dip">
  </TextView>
 </LinearLayout>
 <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" 
  android:layout_below="@+id/search_header" android:id="@+id/list_contents">
  <!-- Stuff you want to show after returning from the AsyncTask -->
 </RelativeLayout>    
</RelativeLayout>

I use this layout for an Activity with an AsyncTask, so onPreExecute(), I do something like:

@Override
protected void onPreExecute(){
 findViewById(R.id.list_contents).setVisibility(View.GONE);
 findViewById(R.id.spinner_layout).setVisibility(View.VISIBLE);
}

And then do whatever I have to do, and onPostExecute() I have:

@Override
protected void onPostExecute(Cursor cursor){
 findViewById(R.id.list_contents).setVisibility(View.VISIBLE);
 findViewById(R.id.spinner_layout).setVisibility(View.GONE);
}
Zarah
  • 5,179
  • 2
  • 29
  • 29
  • hi thanx for letting me know about one more way and still i need to implement the same, and i didn't exactly your idea, can you post the whole XML file for the same layout?? – Paresh Mayani Dec 02 '10 at 09:06