4/14每日总结(app实现浏览功能)

所花时间:2小时

代码量:如下:

博客量:本学期截至目前43篇

了解到的知识点:app预浏览

把pdf导入assets文件里面

然后在build gradle导入依赖:

1
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

  在setting.gradle写进去

1
jcenter()

  在gradle 。properties导入

1
2
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

  MainActivity

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package com.he.liu;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.github.barteksc.pdfviewer.PDFView;
import com.he.liu.R;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PDFView pdfView = findViewById(R.id.pdf);
        pdfView.fromAsset("优秀团员(1).pdf").load();
    }
}

  xml:

1
2
3
4
5
6
7
8
9
10
11
12
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <com.github.barteksc.pdfviewer.PDFView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/pdf"/>
</RelativeLayout>

  

posted @   南北啊  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
1 2 3
4
点击右上角即可分享
微信分享提示