在ListView中更改ImageView的内容可以通过多种方式来实现,以下是两种常用方法:
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
ViewPager viewPager = findViewById(R.id.viewPager);
viewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), getLifecycle()));
// 设置要显示的图片和文字
viewPager.setCurrentItem(0);
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
ImageView imageView = findViewById(R.id.imageView);
// 设置图片的Matrix
Matrix matrix = new Matrix();
matrix.postRotate(angle, imageView.getWidth() / 2, imageView.getHeight() / 2);
imageView.setImageMatrix(matrix);
其中,angle表示旋转的角度,可以根据需要进行调整。
算法大赛
TVP「再定义领导力」技术管理会议
云+社区沙龙online [技术应变力]
TVP技术夜未眠
TVP技术夜未眠
高校公开课
云+社区沙龙online [新技术实践]
领取专属 10元无门槛券
手把手带您无忧上云