StreamingReader.builder().read(file)
答案 0 :(得分:1)
您可以自定义进度条。自定义ProgressBar需要定义进度条的背景和进度的属性。
在res-> drawable文件夹中创建一个名为customprogressbar.xml的XML文件:
custom_progressbar.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape>
<gradient
android:startColor="#000001"
android:centerColor="#0b131e"
android:centerY="1.0"
android:endColor="#0d1522"
android:angle="270"
/>
</shape>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#007A00"
android:centerColor="#007A00"
android:centerY="1.0"
android:endColor="#06101d"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
现在需要在customprogressbar.xml(drawable)中设置progressDrawable属性
您可以在XML文件或Activity中(在运行时)执行此操作。
在XML中执行以下操作:
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/custom_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
At run time do the following
// Get the Drawable custom_progressbar
Drawable draw=res.getDrawable(R.drawable.custom_progressbar);
// set the drawable as progress drawable
progressBar.setProgressDrawable(draw);
答案 1 :(得分:0)
The question makes no sense at all. In the question you creates a ProgressDialog, which is infact a descendent of Dialog. A Dialog always have a background white/dark based on Application theme.
If you want just a Progress bar in the Activity,
Add
<ProgressBar android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pgBar"
android:indeterminate="true" />
in the Activity/Fragment's layout
And Access the Progressbar like this
ProgressBar pgBar = (ProgressBar) findViewById(R.id.pgBar);
pgBar.setIndeterminate(true);
pgBar.setVisibility(View.Visible)
答案 2 :(得分:0)
The default backround for the progress bar is white.We can change the color of the progress bar by using
1. android:progressDrawable in xml OR
2. setProgressDrawable(drawable) method programically.
drawable may be an image directly inseted to drawable folder or create a xml file in drawable folder.xml drawable is prefered since it is more optimal than image.
ProgressBar progessBar = new ProgressBar(MainActivity.this);
Drawable dr=getResources().getDrawable(R.drawable.pink);
pDialog.setProgressDrawable(dr);
where pink.xl is the xml file that describes the background for the progressbar