脉动脉冲/脉冲动画库不起作用

问题描述 投票:0回答:1

我想在我的项目中使用pulseLayout,但无法正常工作,我之所以制作演示项目是为了找出原因,因为它无法得出任何结论。我尝试了2脉冲库,但没有一个工作。lib是:https://github.com/gaurav414u/android-ripple-pulse-animation

https://github.com/booncol/Pulsator4Droid

布局文件:

<?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"
    xmlns:ripple="http://schemas.android.com/tools"
    tools:context=".MainActivity">

    <com.gauravbhola.ripplepulsebackground.RipplePulseLayout
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:clipChildren="false"
        ripple:rippleColor="#3D66C7"
        ripple:rippleType="stroke"
        ripple:strokeWidth="2dp"
        ripple:startRadius="42dp"
        android:layout_centerInParent="true"
        ripple:endRadius="100dp"
        ripple:duration="2000"
        android:id="@+id/layout_ripplepulse">
    </com.gauravbhola.ripplepulsebackground.RipplePulseLayout>


    <pl.bclogic.pulsator4droid.library.PulsatorLayout
        android:id="@+id/pulsator"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:pulse_count="4"
        app:pulse_duration="7000"
        app:pulse_repeat="0"
        android:layout_below="@+id/layout_ripplepulse"
        app:pulse_color="@color/colorAccent"
        app:pulse_startFromScratch="false"
        app:pulse_interpolator="Linear">
    </pl.bclogic.pulsator4droid.library.PulsatorLayout>

</RelativeLayout>

活动:

public class MainActivity extends AppCompatActivity {

    RipplePulseLayout layout_ripplepulse;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        layout_ripplepulse  =findViewById(R.id.layout_ripplepulse);
        layout_ripplepulse.startRippleAnimation();

    }
}

App Level Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.trueapps.wordsearchnewproject"
        minSdkVersion 16
        targetSdkVersion 29
        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.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    implementation 'pl.bclogic:pulsator4droid:1.0.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.gauravbhola.ripplepulsebackground:library:1.0.0'

}

项目级别Gradle:

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // 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
}
android animation lib
1个回答
0
投票

在您使用的Xml文件头中

xmlns:ripple="http://schemas.android.com/tools"

只需替换为

xmlns:ripple="http://schemas.android.com/apk/res-auto"
© www.soinside.com 2019 - 2024. All rights reserved.