4/14每日总结(app实现浏览功能)
所花时间:2小时
代码量:如下:
博客量:本学期截至目前43篇
了解到的知识点:app预浏览
把pdf导入assets文件里面
然后在build gradle导入依赖:
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
在setting.gradle写进去
jcenter()
在gradle 。properties导入
# Automatically convert third-party libraries to use AndroidX android.enableJetifier=true
MainActivity
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:
<?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>

浙公网安备 33010602011771号