Android: Android Thumbnail 攻略

本文探讨了MediaScanner如何生成及保存图片thumbnail,并提供了查询thumbnail的代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文简单研究一下MediaScanner生成及保存thumbnail的方式,并给出代码快速查询图片的thumbnail,

希望可以抛块儿砖,引出一大堆玉来~

1. 手动执行Dev Tools /Media Scanner,或插入SD卡的时候,会启动MediaScannerService,把媒体文件更新到media数据库,

如果是图片文件会同时生成thumbnail

这部分代码在 packages/providers/MediaProvider

2. 数据库中图片及thumbnail的表结构

adb shell进入目录 /data/data/com.android.providers.media/databases

可以看到两个数据库internal.db external-xx.db,其中external.db中保存着sd卡中的媒体信息

我们用sqlit查看一下

sqlite3 external-xx.db

.table

可以看到有很多媒体文件相关的表,我们需要关心images跟thumbnails这个表

images表结构:

view plaincopy to clipboardprint?
images (_id INTEGER PRIMARY KEY,_data TEXT,_s
ize INTEGER,_display_name TEXT,mime_type TEXT,title TEXT,date_added INTEGER,date
_modified INTEGER,description TEXT,picasa_id TEXT,isprivate INTEGER,latitude DOU
BLE,longitude DOUBLE,datetaken INTEGER,orientation INTEGER,mini_thumb_magic INTE
GER,bucket_id TEXT,bucket_display_name TEXT)


thumbnails表结构:

view plaincopy to clipboardprint?
thumbnails (_id INTEGER PRIMARY KEY,_
data TEXT,image_id INTEGER,kind INTEGER,width INTEGER,height INTEGER)


我们看一下在我的模拟器上实际的数据:

select * from images;

view plaincopy to clipboardprint?
4|/mnt/sdcard/Android/1289887991860.jpg|40449|1289887991860.jpg|image/jpeg|12898
87991860|1290054484|1290064872||||||1290064872000|0|-5876966875320966333|1801299
020|Android
8|/mnt/sdcard/20101126062805_hahaha.bmp|65590|20101126062805_hahaha.bmp|image/x-
ms-bmp|20101126062805_hahaha|1290752887|1290752885||||||1290752885000||536666747
8445081544|-1595679508|sdcard
9|/mnt/sdcard/20101126064005_20101126062805_hahaha.bmp|65590|20101126064005_2010
1126062805_hahaha.bmp|image/x-ms-bmp|20101126064005_20101126062805_hahaha|129075
3607|1290753606||||||1290753606000||2418262411059016544|-1595679508|sdcard


select * from thumbnails;

view plaincopy to clipboardprint?
4|/mnt/sdcard/DCIM/.thumbnails/1290054484766.jpg|4|1|400|300
6|/mnt/sdcard/DCIM/.thumbnails/1290752887313.jpg|8|1|128|128
7|/mnt/sdcard/DCIM/.thumbnails/1290753608349.jpg|9|1|128|128


3. 现在可以看到sd卡下面的 DCIM/.thumbnails目录做什么用了,MediaScanner把生成的thumbnail放到这里,

并在数据库中来维护thumbnail跟图片的对应关系:

images表中第一列是图片的id, 对应的thumbnail表中的image_id项

images表中第二列式图片的路径,thumbnail表中第二列是thumbnail的路径

4. 从这个结果我们可以这样来查询某张图片的thumbnail (我自己想的,或许有更好的方法)

当前文件路径 ---> 查询images表得到 _id ---> 用 _id = image_id查询thumbnials表 得到thumbnial 的路径

5. 根据文件路径file_path的到_id:

view plaincopy to clipboardprint?
String[] projection2 = {
"_id",
//"_data"
};
Uri uri2 = MediaStore.Images.Media.getContentUri("external");
String where = String.format(
"_data = '%s' ",
file_path);
Cursor c2 = Media.query(getContentResolver(), uri2,
projection2, where , null);
long image_id = c2.getLong(c2.getColumnIndexOrThrow("_id"));


6. 根据image_id查询thumbnail路径

view plaincopy to clipboardprint?
String[] projection = {
"_data" ,
//"image_id"
};


Cursor c = Thumbnails.queryMiniThumbnail(getContentResolver(), image_id,
Thumbnails.MINI_KIND, projection);


thumbnail_path = c.getString(c.getColumnIndexOrThrow("_data"));



7. 这样就从当前文件得到了对应的thumbnail,前提是MediaScanner帮你扫描过了,当然你也可以在代码中自己启动扫描

然后把thumnail路径传递给你用来显示的ImageView就可以了

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- 标题栏 --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="#44bd32"> <Button android:id="@+id/fanHui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="16sp" /> </RelativeLayout> <!-- 底部按钮 --> <LinearLayout android:id="@+id/footer_buttons" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="horizontal"> <!-- <Button--> <!-- android:id="@+id/device_location"--> <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent"--> <!-- android:gravity="center"--> <!-- android:text="设备定位"--> <!-- android:textSize="19sp"--> <!-- android:background="#44bd32"--> <!-- android:textColor="@android:color/white" />--> </LinearLayout> <RelativeLayout android:id="@+id/video_container" android:layout_width="match_parent" android:layout_height="380dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/toolbar" android:layout_marginBottom="298dp" android:background="@android:color/black" android:padding="0dp"> <!-- 视频播放器 --> <VideoView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> <!-- 播放控制条 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#99000000" android:orientation="horizontal" android:padding="8dp"> <ImageButton android:id="@+id/btn_play_pause" android:layout_width="40dp" android:layout_height="40dp" android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_play_sel" /> <SeekBar android:id="@+id/video_seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="00:00/00:00" android:textColor="@android:color/white" android:textSize="14sp" /> </LinearLayout> </RelativeLayout> <GridLayout android:id="@+id/thumbnail_grid" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/footer_buttons" android:layout_below="@id/video_container" android:layout_marginBottom="300dp" android:background="@android:color/white" android:columnCount="4" android:orientation="horizontal" android:padding="8dp" android:rowCount="2"> <!-- 动态添加的缩略图将放在这里 --> <!-- 示例缩略图 (可选) --> <ImageView android:layout_width="50dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> <!-- 更多缩略图... --> </GridLayout> <ImageView android:layout_width="50dp" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> </RelativeLayout> 把布局文件中2个萤石缩略图放在 android:id="@+id/thumbnail_grid"之中
最新发布
06-27
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- 标题栏 --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="#44bd32"> <Button android:id="@+id/fanHui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="16sp" /> </RelativeLayout> <!-- 底部按钮 --> <LinearLayout android:id="@+id/footer_buttons" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="horizontal"> <!-- <Button--> <!-- android:id="@+id/device_location"--> <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent"--> <!-- android:gravity="center"--> <!-- android:text="设备定位"--> <!-- android:textSize="19sp"--> <!-- android:background="#44bd32"--> <!-- android:textColor="@android:color/white" />--> </LinearLayout> <RelativeLayout android:id="@+id/video_container" android:layout_width="match_parent" android:layout_height="380dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/toolbar" android:layout_marginBottom="298dp" android:background="@android:color/black" android:padding="0dp"> <!-- 视频播放器 --> <VideoView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> <!-- 播放控制条 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#99000000" android:orientation="horizontal" android:padding="8dp"> <ImageButton android:id="@+id/btn_play_pause" android:layout_width="40dp" android:layout_height="40dp" android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_play_sel" /> <SeekBar android:id="@+id/video_seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="00:00/00:00" android:textColor="@android:color/white" android:textSize="14sp" /> </LinearLayout> <GridLayout android:id="@+id/thumbnail_grid" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/footer_buttons" android:layout_below="@id/video_container" android:layout_marginBottom="300dp" android:background="@android:color/white" android:columnCount="4" android:orientation="horizontal" android:padding="8dp" android:rowCount="2"> <!-- 动态添加的缩略图将放在这里 --> <!-- 示例缩略图 (可选) --> <ImageView android:layout_width="50dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> <ImageView android:layout_width="50dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> <!-- 更多缩略图... --> </GridLayout> </RelativeLayout> </RelativeLayout> 把布局文件中android:id="@+id/thumbnail_grid"放置在播放控制条的下面
06-27
shu3.xml:<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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="match_parent" android:background="@drawable/gradient_background" tools:context=".ShuHai3Activity"> <!-- Toolbar --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <Button android:id="@+id/back_button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@android:color/transparent" android:contentDescription="返回上一页" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="19dp" /> </RelativeLayout> <!-- 播放视频区域 --> <!-- 时间线和缩略图区域 --> <FrameLayout android:id="@+id/video_container" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintHeight_percent="0.55" android:background="@android:color/black" app:layout_constraintBottom_toTopOf="@id/thumbnail_scrollview" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.6" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/toolbar" app:layout_constraintVertical_bias="0.0"> <!-- 模拟萤石播放加载动画 --> <ProgressBar android:id="@+id/video_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <!-- 视频播放View,可以替换成具体的视频播放控件 --> <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="视频播放区域" android:textColor="@android:color/white" android:visibility="visible" /> </FrameLayout> <ScrollView android:id="@+id/thumbnail_scrollview" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintHeight_percent="0.45" android:fillViewport="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/video_container"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.GridLayout android:id="@+id/gridLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:columnCount="2" app:rowCount="0" app:alignmentMode="alignBounds" app:useDefaultMargins="true" android:padding="8dp"> <!-- 多个缩略图子项 --> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> <!-- <ImageView--> <!-- android:layout_width="0dp"--> <!-- android:layout_height="wrap_content"--> <!-- app:layout_columnWeight="1"--> <!-- android:layout_margin="4dp"--> <!-- android:adjustViewBounds="true"--> <!-- android:contentDescription="萤石缩略图"--> <!-- android:src="@drawable/default_thumbnail" />--> </android.support.v7.widget.GridLayout> </LinearLayout> </ScrollView> </android.support.constraint.ConstraintLayout> 修改下面shuhaisp.xml布局和上面shu3.xml布局一样,保持shuhaisp.xml依赖不变必须使用android支持库。shuhaisp.xml:<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- tools:context=".ShuhaiSp"--> <!-- <!– 顶部工具栏 –>--> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#44bd32"> <Button android:id="@+id/back_button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:background="@android:color/transparent" android:contentDescription="返回上一页" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="19dp" /> </RelativeLayout> <!-- 视频播放区域 --> <FrameLayout android:id="@+id/video_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/toolbar" android:layout_above="@+id/thumbnail_scrollview" android:layout_marginTop="0dp" android:background="@android:color/black"> <ProgressBar android:id="@+id/video_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="视频播放区域" android:textColor="@android:color/white" android:visibility="visible" /> </FrameLayout> <!-- 缩略图区域 --> <ScrollView android:id="@+id/thumbnail_scrollview" android:layout_width="match_parent" android:layout_height="0dp" android:layout_alignParentBottom="true" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.widget.GridLayout android:id="@+id/gridLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="2" android:rowCount="0" android:alignmentMode="alignBounds" android:useDefaultMargins="true" android:padding="8dp"> <!-- 缩略图示例 --> <!-- <ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_columnWeight="1" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="缩略图" android:src="@drawable/default_thumbnail" /> --> </android.widget.GridLayout> </LinearLayout> </ScrollView> </RelativeLayout>
06-25
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- 标题栏 --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="#44bd32"> <Button android:id="@+id/fanHui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="16sp" /> </RelativeLayout> <!-- 底部按钮 --> <LinearLayout android:id="@+id/footer_buttons" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="horizontal"> <!-- <Button--> <!-- android:id="@+id/device_location"--> <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent"--> <!-- android:gravity="center"--> <!-- android:text="设备定位"--> <!-- android:textSize="19sp"--> <!-- android:background="#44bd32"--> <!-- android:textColor="@android:color/white" />--> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="380dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/toolbar" android:layout_marginBottom="298dp" android:background="@android:color/black" android:padding="0dp"> <!-- 视频播放器 --> <VideoView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> <!-- 播放控制条 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#99000000" android:orientation="horizontal" android:padding="8dp"> <ImageButton android:id="@+id/btn_play_pause" android:layout_width="40dp" android:layout_height="40dp" android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_play_sel" /> <SeekBar android:id="@+id/video_seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="00:00/00:00" android:textColor="@android:color/white" android:textSize="14sp" /> </LinearLayout> </RelativeLayout> </RelativeLayout> 在视频播放器模块下面屏幕剩余位置添加一个放置缩略图的模块<ImageView android:layout_width="0dp" android:layout_height="wrap_content" app:layout_columnWeight="1" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" />
06-27
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient_background"> <!-- 标题栏 --> <RelativeLayout android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" android:background="#44bd32"> <Button android:id="@+id/fanHui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:foreground="?android:attr/selectableItemBackground" android:text="返回" android:textColor="@android:color/white" android:textSize="16sp" /> </RelativeLayout> <!-- 底部按钮 --> <LinearLayout android:id="@+id/footer_buttons" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="horizontal"> <!-- <Button--> <!-- android:id="@+id/device_location"--> <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent"--> <!-- android:gravity="center"--> <!-- android:text="设备定位"--> <!-- android:textSize="19sp"--> <!-- android:background="#44bd32"--> <!-- android:textColor="@android:color/white" />--> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="380dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/toolbar" android:layout_marginBottom="298dp" android:background="@android:color/black" android:padding="0dp"> <!-- 视频播放器 --> <VideoView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> <!-- 播放控制条 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#99000000" android:orientation="horizontal" android:padding="8dp"> <ImageButton android:id="@+id/btn_play_pause" android:layout_width="40dp" android:layout_height="40dp" android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_play_sel" /> <SeekBar android:id="@+id/video_seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="00:00/00:00" android:textColor="@android:color/white" android:textSize="14sp" /> </LinearLayout> </RelativeLayout> <GridLayout android:id="@+id/thumbnail_grid" android:layout_width="match_parent" android:layout_height="301dp" android:layout_above="@id/footer_buttons" android:layout_below="@id/video_container" android:layout_marginBottom="-1dp" android:background="@android:color/white" android:columnCount="4" android:padding="8dp" android:rowCount="2"> <!-- 动态添加的缩略图将放在这里 --> <!-- 示例缩略图 (可选) --> <ImageView app:layout_columnWeight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="4dp" android:adjustViewBounds="true" android:contentDescription="萤石缩略图" android:src="@drawable/default_thumbnail" /> <!-- 更多缩略图... --> </GridLayout> </RelativeLayout> 依据上述代码解决2个报错:Cannot resolve symbol '@id/video_container' Namespace 'app' is not bound
06-27
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值