Дми*_*цов 0 android android-glide
我想创建一个小的动画微调器然后我的图片正在加载。但是出了点问题,或者我可能是瞎子,不明白我应该改变什么。第一个问题是当占位符“加载”时 ViewHolder 很大。
第二个问题是微调器不旋转。如果有人能告诉我我错在哪里,我会很高兴。
XML:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720">
<shape
android:shape="ring"
android:thickness="2dp"
android:useLevel="false">
<gradient
android:angle="0"
android:endColor="@color/cesar_blue_69cff7"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="50dp"
android:layout_marginTop="10dp"
app:cardCornerRadius="10dp"
app:cardElevation="2dp">
<ImageView
android:id="@+id/storeItemImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
tools:src="@drawable/enter_2_car" />
<TextView
android:id="@+id/storeItemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="12sp"
tools:text="someText" />
</androidx.cardview.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
爪哇:
with(containerView) {
GlideApp.with(containerView)
.load("https://i.picsum.photos/id/688/5000/5000.jpg")
.override(290, 78)
.centerCrop()
.placeholder(R.drawable.progress_circle)
.into(storeItemImage)
}
Run Code Online (Sandbox Code Playgroud)
图片:

如果真的没有必要使用自定义 drawable,那么已经有一个CircularProgressDrawable专门用于这种目的的类。您可以创建它的对象,更改其不同的属性并将其用作Glide的占位符。示例代码可能如下所示:
// create a ProgressDrawable object which we will show as placeholder
CircularProgressDrawable drawable = new CircularProgressDrawable(this);
drawable.setColorSchemeColors(R.color.colorPrimary, R.color.colorPrimaryDark, R.color.colorAccent);
drawable.setCenterRadius(30f);
drawable.setStrokeWidth(5f);
// set all other properties as you would see fit and start it
drawable.start();
// now set the drawable as placeholder in glide
GlideApp.with(containerView)
.load("https://i.picsum.photos/id/688/5000/5000.jpg")
.override(290, 78)
.centerCrop()
.placeholder(drawable)
.into(storeItemImage);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1077 次 |
| 最近记录: |