标签: android-progressbar

Android:如何在进度条处于活动状态时禁用控件

我像往常一样在操作栏中显示我的infinte进度条:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
...
setProgressBarIndeterminateVisibility(true);
...
setProgressBarIndeterminateVisibility(false);
Run Code Online (Sandbox Code Playgroud)

并且真正的工作是在后台线程中完成的(AsyncTask)

问题:UI上的所有控件都已启用,因此用户可以在持久过程完成之前继续修改基础数据.

简单地禁用所有控件是不可能的,因为在禁用EditText时,Android也会自动关闭键盘.

有什么想法在后台工作期间如何防止用户输入?

谢谢,

克里斯

android android-layout android-progressbar android-view

14
推荐指数
2
解决办法
2万
查看次数

在Android中以编程方式对中ProgressBar

我正在尝试ProgressBar使用以下内容以编程方式居中:

ViewGroup layout = (ViewGroup) findViewById(android.R.id.content).getRootView();
progressBar = newProgressBar(SignInActivity.this,null,android.R.attr.progressBarStyleLarge);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(progressBar,params);
Run Code Online (Sandbox Code Playgroud)

大小设置似乎工作正常,但ProgressBar不在现有布局(由具有相对布局的xml定义)中.这里有什么明显的错误吗?

XML如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test"
android:typeface="monospace">

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

即它只是一个空的相对布局来测试,看看我是否可以通过编程方式添加进度条.

谢谢.

android android-progressbar

14
推荐指数
3
解决办法
4万
查看次数

ProgressBar Circle在android L(API 21)上没有显示进度

我有一个循环的ProgressBar来计算时间.它完美适用于kitkat之前和之前,但在Android L上它总是显示一个完整的圆圈,无论我设置了什么进展.

图片

layout.xml

<ProgressBar
                android:id="@+id/progressBar1"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:indeterminate="false"
                android:max="200"
                android:progress="100"
                android:progressDrawable="@drawable/progresscircle" />
Run Code Online (Sandbox Code Playgroud)

progresscircle.xml

 <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape
            android:innerRadiusRatio="3.4"
            android:shape="ring"
            android:thicknessRatio="6.0" >
            <solid 
                android:color="#ffffff" />
        </shape>
    </item>
        <item>
            <rotate
                android:drawable="@drawable/progress_particle"
                android:fromDegrees="0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toDegrees="360" />
        </item>

    </layer-list>
Run Code Online (Sandbox Code Playgroud)

android android-progressbar android-5.0-lollipop

14
推荐指数
1
解决办法
6391
查看次数

如何在Android上更改默认的ProgressBar圆圈颜色

我目前在通过gradle导入的Android项目中使用外部库.
此库显示带有ProgressBar圈的通知栏.这是我在其中找到的代码:

<ProgressBar
            android:id="@+id/progress_bar"
            android:layout_height="match_parent"
            android:layout_marginBottom="4dp"
            android:layout_marginTop="4dp"
            style="@style/SuperActivityToast_Progress_ProgressBar"/>
Run Code Online (Sandbox Code Playgroud)

相关的风格是这样的:

<style name="SuperActivityToast_Progress_ProgressBar" parent="android:Widget.Holo.ProgressBar">
    <item name="android:layout_width">32dp</item>
    <item name="android:layout_marginLeft">8dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)

如果我理解相关信息,则显示的圆圈颜色来自默认颜色(手机上的绿色).我需要改变它!

现在,我无法修改源代码,库本身也不能让我以编程方式设置样式.

有一种方法可以在应用级别更改默认样式或更好地覆盖此特定样式?

谢谢戴维德

geometry android styles overriding android-progressbar

14
推荐指数
4
解决办法
3万
查看次数

以编程方式创建和显示进度条

ProgressBar在我的活动中以编程方式创建了以下内容.如何让它显示?

progressBar = new ProgressBar(activity, null, android.R.attr.progressBarStyleSmall);
Run Code Online (Sandbox Code Playgroud)

android android-layout android-progressbar android-activity

13
推荐指数
2
解决办法
2万
查看次数

如何按百分比显示进度条状态

我正在使用android 2.3.3的进度对话框.进度对话框的状态显示格式为"60%60/100",但我想只显示百分比而不是"60/100".我该怎么做?请帮忙.

android android-progressbar

12
推荐指数
3
解决办法
5万
查看次数

改变进度条android的半透明背景颜色

我想改变具有黑色半透明背景的进度条的背景颜色,不透明度小于50%.我搜索了很多关于这个,但无法找到解决方案.我不知道我是否对,但它与进度条的mdecor属性有关.

以下是我使用它的代码.

pd = ProgressDialog.show(getActivity(), null, null,true);       
pd.setContentView(R.layout.remove_border);
Run Code Online (Sandbox Code Playgroud)

删除边框布局的代码是:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical" >

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@android:color/transparent"
    android:indeterminateDrawable="@drawable/my_progress_indeterminate" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

my_progress_indeterminate的代码是:

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loadingiconblack"
android:pivotX="50%"
android:pivotY="50%" />
Run Code Online (Sandbox Code Playgroud)

以下是背景区域以红色圆圈标记的图像.我想用相同的不透明度将颜色更改为白色.

在此输入图像描述

编辑:

感谢Sripathi和user3298272在这里结合两种解决方案的最终解决方案是我的最新答案:

pd = new Dialog(this, android.R.style.Theme_Black);
View view = LayoutInflater.from(this).inflate(R.layout.remove_border, null);
pd.requestWindowFeature(Window.FEATURE_NO_TITLE);
pd.getWindow().setBackgroundDrawableResource(R.color.transparent);
pd.setContentView(view);
pd.show();
Run Code Online (Sandbox Code Playgroud)

remove_border xml代码:这里android:gravity ="center"是我的线性布局代码中添加的.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@android:color/transparent"
    android:indeterminateDrawable="@drawable/my_progress_indeterminate" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

颜色xml代码:

<resources>

  <color name="transparent">#80FFFFFF</color>

</resources>
Run Code Online (Sandbox Code Playgroud)

在#80FFFFFF 80中,我从user3298272获取的不透明度值为50%.

android android-progressbar android-alertdialog

12
推荐指数
2
解决办法
2万
查看次数

Android - 在Lollipop前设备上设置ProgressBar

我的应用程序的最低API级别是19(KitKat),并包含一个水平布局ProgressBar.我正在使用android:progressTint属性将条形色调为自定义颜色.它在Lollipop(API 21)及更高版本上运行良好,但在下面(例如在API 19上)它没有; 它以不同的颜色显示出来.原因是这个属性

仅用于API级别21及更高级别

正如Android Studio所述.

所以我想知道什么是一个很好的替代方案,也可以用来ProgressBar点亮前Lollipop设备.可以使用XML在布局文件中创建吗?或者应该以不同的方式完成?


编辑#1:我的ProgressBar用于显示百分比的具体值,而不是用于指示我的布局正在加载.我想明确这一点,因为在尝试了Kuldeep Kulkarni在下面写的内容之后,我的酒吧看起来像一个材料加载指示器(当然在Lollipop设备上,而不是KitKat设备上的任何可见结果).

android android-layout android-progressbar android-api-levels

12
推荐指数
4
解决办法
1万
查看次数

更新列表视图中的进度条以下载多个文件

我们如何更新ListView中的进度条.当每个进度条与文件下载相关联时,通过AsyncTask完成.

该功能将是:

  1. 每个进度条都将通过下载过程进行更新.
  2. 当文件完成下载后,它将保存到SD卡中.
  3. 它将添加它服务(在后台运行.
  4. 下载一个文件时,应显示"完成"(不应删除表单列表视图)

我还使用数据库下载文件.该列表还取决于数据库向量.我该如何实现它.我也试过但没有得到解决方案.

以下是详细描述它的两个屏幕截图:

在此输入图像描述

我也试过这段代码:

temp = databaseHandler.getAllNotifyNumber();
list_download = (ListView) findViewById(R.id.list_download);
myCustomAdapter = new MyCustomAdapter(mContext);
list_download.setAdapter(myCustomAdapter);
myCustomAdapter.notifyDataSetChanged();

for (int index = 0; index < temp.size(); index++) {
    String url = "http://upload.wikimedia.org/wikipedia/commons/0/05/Sna_large.png";
    grabURL(url);
}
Run Code Online (Sandbox Code Playgroud)

这是AsyncTask mathod:

  public void grabURL(String url) {
    new GrabURL().execute(url);
}

private class GrabURL extends AsyncTask<String, Integer, String> {

    protected String doInBackground(String... urls) {

        String filename = "MySampleFile.png";
        File myFile = new File(directory, filename);

        try {
            URL url = new URL(urls[0]);
            URLConnection connection …
Run Code Online (Sandbox Code Playgroud)

android download android-listview android-progressbar android-asynctask

11
推荐指数
1
解决办法
4357
查看次数

ContentLoadingProgressBar永远不会显示

我用我的片段替换了简单ProgressBarContentLoadingProgressBar.现在片段布局如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            style="@style/simple_match_parent_style">

<android.support.v4.widget.ContentLoadingProgressBar
            android:id="@+id/progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>

<TextView
    android:id="@+id/txt_no_songs"
    android:text="@string/txt_no_songs"
    android:layout_centerInParent="true"
    style="@style/txt_no_songs"/>

<ListView
    android:id="@+id/list"
    android:fastScrollEnabled="true"
    android:divider="@null"
    style="@style/simple_match_parent_style"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我将此ProgressBar显示在onViewCreated:

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.progress);
    progressBar.show();
    ...
}
Run Code Online (Sandbox Code Playgroud)

出于测试目的,我已删除progressBar.hide()调用以使ProgressBar出现在任何情况下.但问题是我ContentLoadingProgressBar从未真正展示过.

我应该做些别的事ContentLoadingProgressBar吗?我没有设法找到任何相关的使用示例,ContentLoadingProgressBar因此任何有用的示例也是可取的.提前致谢.

android android-progressbar

11
推荐指数
2
解决办法
9829
查看次数