简体   繁体   English

如何创建和绘制在从视图扩展的 class 中创建的进度条

[英]How to create and draw a progress bar that is created in a class that extends from View

I want to know if it is possible to create a progress bar that is created in a class that extends from the class View?我想知道是否可以创建在从 class 视图扩展的 class 中创建的进度条?

My intention is to add a progress bar in my animation, using the "On a View" structure for creating animations in android:我的意图是在我的 animation 中添加一个进度条,使用“On a View”结构在 android 中创建动画:

http://developer.android.com/guide/topics/graphics/index.html http://developer.android.com/guide/topics/graphics/index.html

I tried with the fallowing way, in the view class, but it didn't appear.我尝试了休闲方式,在视图 class 中,但没有出现。

public class CustomDrawableView extends View {
    private ProgressBar mProgress;

    public CustomDrawableView(Context context) {
        super(context);
        mProgress = new ProgressBar(context, null, android.R.attr.progressBarStyleSmall);
    }

    protected void onDraw(Canvas canvas) {
        mProgress.draw(canvas);
    }
}

Any suggestion?有什么建议吗?

Greetings问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在线程列表视图中的进度栏​​中设置下载进度? - How to set download progress in a progress bar that is in a list view from thread? 如何将数据从MainActivity传递到类扩展了View - How to pass data from MainActivity to class extends View 从另一个将活动扩展到扩展视图的类的类访问变量 - Acces to variable from another a class that extends activity to a class that extends view 如何获取扩展片段/活动等的 class 的 class 的视图 - How to get the View for a class, that extends a class that extends Fragment/activity etc 如何从不扩展Activity,Android的类中创建DatePicker? - How to create a DatePicker from class which do not extends Activity, Android? 如何从“扩展应用程序”类创建意图,上下文为空 - How to create an intent from an “extends Application” class, context is null 如何从不扩展 Activity、Android 的类创建 TimePicker? - How to create a TimePicker from class which do not extends Activity, Android? 如何通过扩展DialogFragment的类创建对话框? - How to create a dialog from a class which extends DialogFragment? 无法从扩展DialogFragment的类创建默认构造函数,并且我已创建自己的自定义构造函数 - Cannot create a default constructor from a class that extends DialogFragment and I have created my own custom constructor 从扩展Activity的类中调用View - Call a View from a class which extends Activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM