rey5137 / material

A library to bring fully animated Material Design components to pre-Lolipop Android.
http://rey5137.com/material/
Apache License 2.0
6.01k stars 1.32k forks source link

ProgressView in Activity #51

Open wznshuai opened 9 years ago

wznshuai commented 9 years ago

like this code <com.rey.material.widget.ProgressView android:id="@+id/progress_pv_circular" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" app:pv_autostart="true" app:pv_circular="true"/>

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_progress); ProgressView pv_circular = (ProgressView)findViewById(R.id.progress_pv_circular); pv_circular.start(); } in new activity can't run, but, in your demo ProgressFragment it's good

what need i do?

rey5137 commented 9 years ago

Did your activity use a theme of AppCompat? Here is an example:

     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->

        <!-- colorPrimary is used for the default action bar background -->
        <item name="colorPrimary">@color/colorPrimary</item>

        <!-- colorPrimaryDark is used for the status bar -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <!-- colorAccent is used as the default value for colorControlActivated
             which is used to tint widgets -->
        <item name="colorAccent">@color/colorAccent</item>

        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight & colorSwitchThumbNormal. -->
    </style>

The default style of circular progress use colorPrimary attribute of theme.

wznshuai commented 9 years ago

first, thank you very much :)
but , i do with your code in my activty, in > 11 android sdk version it's good, in 2.3 emulator not run. i'm sorry, my english very poor, soory, i'm chinese

wznshuai commented 9 years ago

The 2.3 problem it appears to be in CircularProgressDrawable.java

private void start(boolean withAnimation){ if(isRunning()) return;

    if(withAnimation){
        mRunState = RUN_STATE_STARTING;
        mLastRunStateTime = SystemClock.uptimeMillis();
        mProgressState = PROGRESS_STATE_HIDE;
    }
    else   
        resetAnimation();

    scheduleSelf(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION);
    invalidateSelf();  
}

The scheduleSelf(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); dont't work