我有简单的布局与ImageView的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.example.vbusovikov.glidetest.MainActivity">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
和简单的滑翔表达将图像加载到这个ImageView的只是为了测试滑翔
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = (ImageView)findViewById(R.id.image);
Glide.with(this)
.load("http://you-ps.ru/uploads/posts/2013-08/1376601606_1273.png")
.error(R.mipmap.ic_launcher)
.into(imageView);
}
然而,示出了错误图标。什么样的问题可以吗?我有我的网络上的代理服务器,并为这种情况下,适当gradle.properties。
systemProp.http.proxyHost=proxy******.ru
systemProp.http.proxyPort=****
但是,即使我尝试推出任何代理以外的这个小应用程序,也不会出于某种原因。
我的build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.vbusovikov.glidetest"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
testCompile 'junit:junit:4.12'
}
UPD。这个简单的应用程序可以从互联网加载的图片,但它不能从我的服务器加载图片。我的服务器的一些照片被加载罚款,但有些则没有。我失去了与这个已
它在我的side..check网络工作正常,并没有忘记添加Internet权限清单中。:)
尝试添加占位符标记太(看起来很奇怪,但这个固定的我就在我身边)
Glide.with(YourActivity.this)
.load("http://you-ps.ru/uploads/posts/2013-08/1376601606_1273.png")
.error(R.mipmap.ic_launcher)
.placeholder(R.mipmap.placeholder)
.into(imageView);
不幸的是,所有的答案是正确的,但在我的条件不工作。服务器设置不适合从它下载图片。
== ==更新
过了一会儿,我想通了,我的服务器上的图片被打破。您可以检查您的图片在提供的网址在Mozilla Firefox浏览器打开此URL有效。在图片上几千字节可能会被删除,但像谷歌的Chrome浏览器会忽略并显示图像正常。不过,Firefox是比较敏感的,所以它可以帮助本地化的问题。
使用https而不是http在图像的URL。