我正在为 Android studio 编写代码,我需要 Page Indicator 和 viewpagerindicator.CirclePageIndicator 但它们告诉我错误,所以我无法编译我的代码。 我需要每个 fragment 的底部都有指示器 如果你有一个简单的方法来做到这一点,请告诉我,因为我有 2 天时间搜索如何为每个页面制作带有指示器的方法 我已经从 github 上试过了,但没有用。
https://github.com/vivchar/ViewPagerIndicator
这是我在构建gradle中的代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.zhuniqia.searchfinal"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是主要的 xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="#FF000000"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<viewpagerindicator.CirclePageIndicator
android:id="@+id/pagerIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:padding="3dp"/>
</LinearLayout>
这是Java
public PageIndicator indicator;
最佳答案
Gradle
第 1 步。将 JitPack 存储库添加到您的构建文件
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
第二步,添加依赖
dependencies {
implementation 'com.github.vivchar:ViewPagerIndicator:${LATEST_VERSION}'
}
我在您的 build.gradle 文件中没有看到这些依赖项。另外,请再次阅读并按照您共享的链接中 README 文件中的步骤进行操作。
关于android - Android 项目无法在 Page Indicator 和 CirclePageIndicator 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53269133/