how to get background image in android (java) - java

I want to get background image of Home screen programmatically in Android and set it to background in my activity in my App.
How can i get background image? please guide me.

like this
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
use the drawable the way you want

Related

how to set drawable background of edit text programmatically

Hello every one I am new in the android studio I have a picture in my drawable folder and I want it to save the picture as a background of the edit text programmatically for this I write a code bellow but its not working and it showing a red line error
here is my code.
edit_text.setBackground(R.drawable.background1);
any idea for this how I will write it
please don't suggest me another post as I am new here.
You should retrieve the background drawable using ContextCompat.getDrawable method:
edit_text.setBackground(ContextCompat.getDrawable(this, R.drawable.background1));

In Android Studio How to make Validation for imageview?

How to make validation in android studio for image view.
E.g. I have button when i click on button it open a gallery and i select image it comes in image view but how to set that if someone not upload image it will show message till not upload image in image view
Thanks.
The uri or bitmap that you use to save the image, use it in sharedPreferences. So that when the default value is null user will get the message but when you add a new image it will overwrite the default value of sharedPreferences and hide the messgae.

How to display an image in Dialog using Glide?

in my app there is an dialog with an image on it.
How can I display an image using glide?
Here is what I tried in my Fragment:
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.goldversiondialog)
.error(R.drawable.goldversiondialog);
Glide.with(getActivity()).load(myURL).apply(options).into(goldimageview);
It is not working, it only displays the error image.
I also don't know what to write as context, "this" is not working in fragments.
How can I solve this?

How to fade background of sliding layer in Android

I am implementing a Sliding layer as shown in this link
I need to fade or gray out the background when I open the sliding layer just like the play store app does in below screen shot
I tried using:
Window window = slidingView.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.CENTER_VERTICAL;
wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
wlp.dimAmount = (float) 1.0;
window.setAttributes(wlp);
But this doesn't seem to work...nor does
android:theme="#android:style/Theme.Translucent"
Can anyone tell me how to solve this?
If the purpose is to create the same layout as in Google Play consider using DrawerLayout.
Here is an example
That layout allows you even easily change fade color and alpha via setScrimColor method. The default color is #99000000

Android - Display image that is of type file

I have an image that is currently stored in variable of type "File"..
File img = ...;
What is the easiest way to display this image onto the screen so I can verify it is working correct?
Thanks!
If you have an ImageView in your layout, you can do something like this, assuming you have a reference to your ImageView named view:
Drawable d = Drawable.createFromPath(img);
image.setImageDrawable(d);

Categories

Resources