my problem is that in version 4.2 the background in LinearLayout not showing, but in previous version it showing. I put the background like this:
android:background="#drawable/image"
I don't understand why.
I was just having the exact same problem. What fixed it for me was making sure I had the proper versions in the proper drawable-xxxx folder. For example...
If your image is in res/drawable but not in any other folder like res/drawable-hdpi, res/drawable-xhdpi, etc make sure you create a version appropriate for each of the screen sizes you are supporting and include that version in the corresponding drawable folder.
After I did that my bg drawable started showing up.
maybe it helps someone..I had a problem too with version 4.1.1 and everything I do was to set background programmatically
myLayout.setBackground(yourDrawable);
There isn't any problem with the syntax you are using. May be you are having some other problem. My advice would be to-
Try cleaning the project and run it again.
Check if you have the image named 'image.xxx' in your drawable folder.
Check if you are setting background of the correct layout.
or perhaps you can post some more code so that we can answer you more specifically.
Adding to the Above answer, check that the name of the image in drawable folder is in lower-case. All the drawables must have lower-case names.
Related
This is my project folder, when i adding first image then it not show any error but after adding the 2nd and 3rd image it show the red lines.
I don't know where i do mistake, if anyone knows then please help me.
In Android Studio, click on View > Tool Windows > Resource Manager in the menus or click on the Resource Manager tab to the left of the Project window.
Click the + below Resource Manager, and select Import Drawables. This opens a file browser.
Make sure the name of the image you are trying to add does not resemble some keyword. I was trying to add an image in drawable with name "try". When i made it "tried" error went away. So, name your image != any keyword.
FOR YOUR CASE IN PARTICULAR:
Try invalidating cache and restarting it. Moreover, also check if the problem persists only with these two images or others too.
Names should be in lowercase.
Therefore never use names with uppercase letters in it
try removing numerals and keep a meaningful name. Also ensure that the names are in lower case
drawable folder is wrong place for png files.
In drawable are stored xml files
All png files should be stored in mipmap folders
If you want have only one png for all resolutions, store it in mipmap-anydpi
I found the problem.
Add the same image to the default drawable folder. Android Studio automatically doesn't add it to the default drawable folder.
It usually happen because of the name assigned to image file. try to put the name of file in snake_case.[error][solution]
solutionC.pngerror
I am trying to do a drawer activity with Android Studio and I'm wanting to personalize the icons used. I've downloaded the icons I want to use and for the most part, it's okay.
In fact, I can modify all the android:icon icons but I have no idea how to modify the app:srcCompat icons. I don't know how to detect the image I want to use in this case...
Do you know how I can do it? Could you explain this to me?
Thanks a lot!
Edit: The file I'm working on as a base is the generated project with Drawer activity as the main activity. For example, if I wanted to modify the icon in the nav_header_main.xml file, how could I do to have my image (.png) transformed in a way detected by Android Studio as compatible with srcCompat
Ensure your image file is in res/drawable folder(or drawable-xhdpi/xxhdpi, determined by your design)
Refer it by app:srcCompact="#drawable/$IMAGE_FILE_NAME" in your xml.
Then you should see what you want.
Please check the doc to further understand the official usage.
Well... I was blind! I was wondering how I could add my icons but they were, I was just mistaking on the address... #android:drawable/... is obviously not #drawable/... but I didn't notice. So be aware that there is a difference and it'll be okay I think!
I'm brand new both to Xamarin and the Rider IDE, but not to Android. I'm going through some test projects, but when I make a new project, the ProjectName/Resources folder is missing things that I would expect to be there, most notably drawable. How can I create or get access to those directories so that I can do something like set the app icon?
I've tried creating a drawable directory, including it, and making sure that the build action is set to AndroidResource, but when I add Icon = #drawable/icon.png in the MainActivity, it doesn't recognize the drawable tag.
I found a solution for this. As I mentioned, I created the drawable folder manually, added the icon to it and made sure to right click and Include it. Then, in the manifest, I added android:icon="#drawable/icon and that got the icon to show up properly. So it didn't fix the issue of the folders not being generated, but at least for a simple task like updating the icon, it worked.
You can also declare in xaml.cs file, in your xaml form constructor the following:
x:Name_of_your_image/icon.ImageSource = (FileImageSource) ImageSource.FromFile("image/icon_name");
This way you won't need the drawable folders, as it will automatically provide the source of the image.
This is the folder with all the icon files
Now in my manifest, I'm not sure how to go about adding these icons.
android:icon="#drawable/"
Not sure what to put =/
I've tried putting #drawable/ic_mood_black_48dp and it still doesn't work
Put
android:icon="#drawable/ic_mood_black_48dp"
Those folders are for different resolution screens, and the appropriate png will be automatically shown based on device resolution. The name remains same for all of them, so this should be enough.
Android Studio should autocomplete your typing in the manifest as you type it:
android:icon="#drawable/ic_mood_black_48dp"
I had to move all the drawable folders outside of the folder 'drawable'.
i want have an image and i want to set it as a background of android list view
i have used android:background="drawable/image" but nothing happened
can any one guide me how to achieve this?
any help would be appricated.
Perhops
android:background="#drawable/image"
noticing the #
Also make sure your project's res/drawable folder contains a valid image file called image.jpg or image.png.
Adding to Jim, clean or re-open the project to ensure your newly added image file gets reflected in the /res/drawable folder