PDF Viewer app in android studio , PDF Viewer Application – How to design pdf android app in android studio with source code , in this have upload your own pdf file than open it on app easily .
- minSdkVersion 21
- targetSdkVersion 30
- versionCode 1
- versionName “1.0”
- Android studio 4.0.1
MainActivity.java
package com.technic.pdfviewer;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.github.barteksc.pdfviewer.PDFView;
public class MainActivity extends AppCompatActivity {
private int current_page=0;
EditText textEdit;
TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PDFView pdfView=(PDFView)findViewById(R.id.pdfView);
pdfView.fromAsset("rub.pdf") .load();
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:weightSum="1">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="352dp"
android:layout_weight="1.18" />
</LinearLayout>
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.technic.pdfviewer">
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ADD DEPENDENCY IN GRADLE FILE
implementation 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
implementation 'com.github.barteksc:android-pdf-viewer:1.4.0'
YOUTUBE VIDEO
gradle.app
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.technic.pdfviewer"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
implementation 'com.github.barteksc:android-pdf-viewer:1.4.0'
}
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
READ MORE ANDROID APPS
Wallpaper Android App- CLICK HERE
All IN ONE Status Saver App – CLICK HERE
Photo Video Maker Android App – CLICK HERE
Video Downloader Android App – CLICK HERE
College Student Portal System App – CLICK HERE
Call Recorder Android App – CLICK HERE
PDF Reader App with firebase – CLICK HERE
ShareIt Clone App – CLICK HERE
Design Grid Layout and Card layout – CLICK HERE
Modern Profile UI Design – CLICK HERE
ShareTweetShare