Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在android中更改自定义进度条宽度_Android - Fatal编程技术网

无法在android中更改自定义进度条宽度

无法在android中更改自定义进度条宽度,android,Android,尝试从资源、从XML更改它 ProgressBar progressBar=new ProgressBar(this,null,android.R.attr.progressBarStyleHorizontal); progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_bar)); progressBar.setMinimumWidth(100); 编辑: 如果您想

尝试从资源、从XML更改它

  ProgressBar progressBar=new ProgressBar(this,null,android.R.attr.progressBarStyleHorizontal);
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progress_bar)); 
    progressBar.setMinimumWidth(100);

编辑:


如果您想在运行时更改它,请查看链接。

我以编程方式创建了所有代码。我想创建与vlc player两端计时器相同的进度条。请参阅我编辑的答案。仍然无法正常工作,但其宽度无法更改。我的进度条是我在代码上更改的自定义进度条。它对输出没有影响为什么不从XML使用它呢。您可以在运行时膨胀该XML,并将其作为子视图添加到视图中
<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true" />