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> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)