ProgressBar dialog Without Border

前端 未结 2 1486
小鲜肉
小鲜肉 2021-01-16 11:25

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

\"alt

but there is a

相关标签:
2条回答
  • 2021-01-16 11:47

    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);
    }
    
    0 讨论(0)
  • 2021-01-16 11:48

    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.

    0 讨论(0)
提交回复
热议问题