bitte jede Hilfe zu setzen, ich versuche Bild als Hintergrund einstellen bekomme ich dieses Bild durch ihre url ich mit Arbeit bin Glide Bibliothek ich diesen Code versucht Set image as wallpaper from url aber funktioniert bei mir bitte keine Hilfe um dieses Problem zu lösen?wie Bild-URL als Hintergrundbild (Glide Library)
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>
danke für die Antwort, aber dieser Code funktioniert nicht für mich, ich stelle dies 'Glide.with (getApplicationContext()) .Load (URL) .asBitmap() .Fehler (R.Drawable.arrw). CenterCrop() .into ((ImageView) findViewById (R.id.imageSelectTo)); 'innerhalb von Onclick und wenn ich als Hintergrundbild-Taste drücke Nothing happens – user7959932
Bist du sicher, dass du das Bild auf dem wallpaper imageView aufblähst und nicht irgendeine andere Ansicht, sondern sofort bindst und das ImageView mit einem Image aufzublasen, ist keine gute Übung. Ich denke, Sie sollten eine separate Methode zum Anhängen von Widgets haben. Bitte zeigen Sie auch Ihren XML-Code in Frage. – Athelon
Stellen Sie außerdem sicher, dass Sie das Bild über die URL empfangen. – Athelon