Android 10.0 适配问题都解决了
项目源码.
呈现效果
设计步骤
-
第一步:先定义两个Activity,一个获取数据并用来展示,一个展示媒体库图片并提供选择
MainActivity<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="pickImages" android:text="获取图片" android:textSize="20dp" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/showPicM" android:layout_width="match_parent" android:layout_height="match_parent"/>
PackageImageActivity
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image3" />
<TextView
android:id="@+id/finished_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="(0/9)完成"
android:textColor="#000000"
android:textSize="20dp"
android:onClick="finishedPic"
/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/showImages"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
-
第二步: Android6.0以后的动态申请权限。
private void checkReadPermission() { int readPermission = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE); int