vous plaît toute aide, je suis en train de mettre l'image comme fond d'écran que je reçois cette image par son url je travaille avec Glide Library j'ai essayé ce code Set image as wallpaper from url mais ne fonctionne pas pour moi s'il vous plaît toute aide pour résoudre ce problème?comment définir l'URL de l'image comme fond d'écran (Library Glide)
file.java:
public class Pop extends Activity {
int width,height;
String url;
LinearLayout llsetwallpapers;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pop);
llsetwallpapers = (LinearLayout)findViewById(R.id.llSetWallpaper);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
this.width = dm.widthPixels;
this.height = dm.heightPixels;
getWindow().setLayout((int) (((double) this.width) * 0.9d), (int) (((double) this.height) * 0.75d));
getIntent().getSerializableExtra("WallpaperURL");
this.url = (String)getIntent().getSerializableExtra("WallpaperURL");
Glide.with(getApplicationContext()).load(this.url).into((ImageView)findViewById(R.id.imageSelectTo));
llsetwallpapers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// set as wallpapers
}
});
}
}
xml:
<?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"
android:id="@+id/linealL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#65000000">
<ImageView
android:id="@+id/imageSelectTo"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
<!-- Set as wallpaper button -->
<LinearLayout
android:id="@+id/llSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:background="@drawable/btn_rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_alignParentLeft="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/SetAsWallpaper"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
<!-- Download wallpaper button -->
<LinearLayout
android:id="@+id/llDownloadWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/btn_rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/Download"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
merci pour la réponse, mais ce code ne fonctionne pas pour moi j'ai mis ce 'Glide.with (getApplicationContext()). Load (url) .asBitmap() .error (R.drawable.arrw) .centerCrop() .into ((ImageView) findViewById (R.id.imageSelectTo)); 'inside Onclick et quand je clique comme fond d'écran button Rien ne se passe – user7959932
Etes-vous sûr de gonfler l'image sur le fond d'écran imageView et pas d'autre vue, d'autre part lier immédiatement et gonfler l'imageView avec une image n'est pas une bonne pratique je pense, vous devriez avoir une méthode distincte pour attacher des widgets. Veuillez également montrer votre code XML en question. – Athelon
Assurez-vous également et vérifiez que vous recevez l'image via l'URL. – Athelon