如何使操作栏中的自定义进度条? [英] How can I make a custom progress bar in the action bar?

查看:176
本文介绍了如何使操作栏中的自定义进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是没有那么多的操作栏,尽可能多地创造,我需要帮助的自定义进度条。我想创建一个酷似捕捉注意 - https://ssl.gstatic.com/android /market/com.threebanana.notes/ss-480-0-9 https://market.android.com/details?id=com.threebanana .notes

我已经试过多次以多种不同的方式。我已经看了很多教程,包括Android开发指南。我是pretty的很多愤怒在这一点上。会不会有人给我一些帮助,好吗?

现在,我的操作栏是调用一个通用的进度条的布局和工作正常。

 开关(item.getItemId()){
    案例R.id.refresh:
        item.setActionView(R.layout.progress);
        返回true;
 


 < XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =match_parent机器人:weightSum =1>

<进度机器人:ID =@ + ID /进步
风格=机器人:ATTR / progressBarStyleSmall
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /进度>

< / LinearLayout中>
 

解决方案

为了使进度条显示出来,您需要打开ActionBar.DISPLAY_SHOW_CUSTOM在ActionBar.displayOptions。

抓票据使用自定义动画的进度条。我觉得默认的Holo(正常大小)一个是一个合理的选择,但要达到这样的具体的一个,你要创建一个animationDrawable。

http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

然后您可以通过动作条与getCustomView()的自定义视图,找到你的ImageView,并启动动画。

It's not so much the action bar, as much as it is creating a custom progress bar that I need help with. I want to create one exactly like Catch Notes - https://ssl.gstatic.com/android/market/com.threebanana.notes/ss-480-0-9 https://market.android.com/details?id=com.threebanana.notes

I've tried multiple times in multiple different ways. I've looked at numerous tutorials including the Android Dev Guide. I'm pretty much angry at this point. Will someone offer me some help, please?

Right now, my Action Bar is calling a generic progress bar layout and that works fine.

switch (item.getItemId()) {
    case R.id.refresh:
        item.setActionView(R.layout.progress);
        return true;


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:weightSum="1">

<ProgressBar android:id="@+id/progress" 
style="?android:attr/progressBarStyleSmall"  
android:layout_width="wrap_content" 
android:layout_height="wrap_content">
</ProgressBar>

</LinearLayout>

解决方案

To make the progress bar show up, you need to turn on ActionBar.DISPLAY_SHOW_CUSTOM in ActionBar.displayOptions.

Catch notes is using a custom animation for their progress bar. I think that the default Holo (normal-sized) one is a reasonable alternative, but to get something like their specific one, you'll want to create an animationDrawable.

http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

Then get the custom view from the ActionBar with getCustomView(), find your ImageView, and start it animating.

这篇关于如何使操作栏中的自定义进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆