我正在使用通用图片加载器为谷歌地图中的自定义信息窗口加载图片。我想添加进度条,同时加载图像。
我试过了,但它没有旋转:(
这里有一段加载图片的代码:
final ImageView image = ((ImageView) view.findViewById(R.id.badge));
final ProgressBar spinner = (ProgressBar) view.findViewById(R.id.progress);
imageLoader.displayImage(url, image, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
spinner.setVisibility(View.VISIBLE);
image.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri,View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
image.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
getInfoContents(marker);
}
});
custom_info_window.xml中的ImageView和ProgressBar:
<ImageView
android:id="@+id/badge"
android:layout_width="285dp"
android:layout_height="270dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:adjustViewBounds="true" />
<ProgressBar
android:id="@+id/progress"
android:layout_width="285dp"
android:layout_height="270dp"
android:layout_gravity="bottom"
android:indeterminate="true"
style="@style/ProgressTheme"
android:max="100" />
green_progress.xml:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720"
android:repeatCount="infinite">
<shape
android:innerRadiusRatio="5"
android:shape="ring"
android:thicknessRatio="15"
android:useLevel="false" >
<size
android:height="48dip"
android:width="48dip" />
<gradient
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#c1d82f"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape>
风格:
<style
name="ProgressTheme"
parent="@android:style/Widget.ProgressBar.Large" >
<item name="android:indeterminateDrawable">@drawable/green_progress</item>
</style>