gpt4 book ai didi

java - 无法使用 photoview 库缩放图像

转载 作者:太空宇宙 更新时间:2023-11-04 11:05:19 25 4
gpt4 key购买 nike

我正在使用 here 中的 PhotoView 库。它没有给出任何错误,但我无法缩放图像。尝试缩放图像时没有任何反应。我也没有从 build.gradle 收到任何错误。我该如何解决这个问题?

FullImageActivity.java:

public class FullImageActivity extends AppCompatActivity {
int position;
int folderPosition;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_image);
Intent i = getIntent();
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);


// Selected image id
position = i.getExtras().getInt("id");
folderPosition = i.getExtras().getInt("folderPosition");
Bundle extras = getIntent().getExtras();
String value = extras.getString("abc");

Glide.with(FullImageActivity.this)
.load(value)
.skipMemoryCache(false)
.into(photoView);

ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager);
mViewPager.setAdapter(new TouchImageAdapter(this,al_images, folderPosition));
mViewPager.setCurrentItem(position);
}
}

activity_full_image.xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/jazzy_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"/>


</LinearLayout>

构建.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.example.dell_1.Myapp3"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceCompatibility = '1.7'
targetCompatibility = '1.7'

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.ss.bannerslider:bannerslider:1.8.0'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'com.github.barteksc:android-pdf-viewer:2.7.0-beta.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
testCompile 'junit:junit:4.12'
compile 'org.jetbrains:annotations-java5:15.0'
}

最佳答案

试试这个代码:

  Glide.with(FullImageActivity.this)
.load(value)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
photoView.setImageBitmap(resource);
}
});

关于java - 无法使用 photoview 库缩放图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46537291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com