My laucher icon is glitching, its cut into half - android

as title says, my ic_launcher cut into half, here is the pic
this is the original:
how did this happen, is there any suggestion?

Try using a png file.
or simple right click on your project, select new and then choose Image Asset. Now you will have plenty of options.
It should work

I suggest you use the following method.
Right click on drawable: new ->Image Asset
Select Launcher Icon in asset type
Select the path of the image you want to use as icon and keep the name as ic_launcher only.
next and finish.
You can customize it using the different checkboxes and options.
This should work for the launcher icons.
ps: not enough reputation to comment, so posting as a new answer. :/

Related

How to change icon colors in android studio

I downloaded some icons from material.io but they only offer the icons in black. I saw a youtube video where they use to allow you to choose the color. Anyway, I am trying to change the colors of the icons to white. I am not having any luck. I tried to change the fill color in android studio but it doesn't work. Any assistance would be appreciated such as exact code and files to add the code to. Thanks.
simply you can use
android:tint="#android:color/white"
You can directly download these images in Android Studio.
res > right click > New > Image Asset and select
Icon Type : Action Bar and Tab Icones
Asset Type : Clip Art
Theme : CUSTOM
And you can select any clip art that you want, select the color, padding, etc ...
As mentioned before, the material.io icons can be downloaded directly with Android Studio. This solution shows the importing of vector asset icons which are easier to manage since they are stored in a single location (res/drawable) vs. image assets that will have each icon stored in specific density folders (hdpi, xhdpi, etc).
expand the "res" folder
right click drawable
hover over "new"
select "Vector Asset"
click the image next to "icon"
select desired material.io icon
Name the icon what you would like
select "next"
Now you will have two options of setting the icon color
In the layout by using the android:tint attribute of an ImageView. This is my preference because the icon can be viewed prior to runtime.
or
In Java.
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
https://material.io/icons/ actually does let you download icons in white.
But, depending on what exactly you want to do, there are a few options. If you simply want white icons (and not to change them at runtime), you may find this plugin for Android Studio useful: https://github.com/konifar/android-material-design-icon-generator-plugin
It allows you to generate the material design icons right in Android Studio, in whatever color you want. Another alternative for downloading these icons in different colors is https://materialdesignicons.com/.
If you do want to color the icons at runtime, try something like this:
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.MULTIPLY);
You can download white icons from material.io. also look at themes and theme overlays
Instead of android:src
I use attribute android:foreground
android:foreground="#drawable/ic_add"
For those not getting what they want yet try changing the PorterDuff mode, the following is what did it for me
imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
PorterDuff.Mode.SRC_ATOP);
maybe
app:iconTint help you, I am writing this because of the following reference.
Material Design 3

Android Studio Adding image asset not working

I'm trying to add an image in Android studio by right clicking on the drawable folder->new->Image Asset, I add an Action Bar and Tab Bar icon with a custom image and I click finish and it looks like its doing something but nothing appears in the drawable folder. I'm also unable to reference the new image name in any xml. What's funny is if I go to re-add this image, it says the image already exists and it will be overwritten. Am I doing something wrong?
I create a new project with Android Studio and generate image asset in the new project. It begins to work. I don't know what's wrong with the previous project. Hope it also helps for you.
As #Varun said, Before click on Finish, check save path by click on "Next" button.
TLTR: fix any other icon type you touched before.
In my case it was because of wrong path to foreground image path (the source image was deleted):
So even after changing the icon type the error does not disappear (buttons are disabled):
So fix other icon types.
In Background Layer set Asset Type to "Color"

The colored image turned to have no color and just a grey vector in drawable?

I have created a new Image Assets in the Drawable cus I need to insert a new image in my app, but every time I create a new image asset, the output turns to be no colour at all. I've attached the pic of it.
It's confusing and whenever I import it in my layout, it's just grey all over as you can see in the image. Why is it cus I can't find any ready solutions? Let me know if I'm overlooked.
I got the answer for my own question which I find it's useful for some who still do not know how to enable the Batch Drawable Import. It's easy and just need to download plugin and install. I've read that the latest version already has it and I've downloaded and reinstalled, but it didn't show as what I was expecting. The solution is to download and install it.
First, In Android Studio, go to Default Setting File --> Setting or you can simple Click the SDK Manager Icon
In the Default Setting, go to Plugins
In the search option, type Batch Drawable Import and you'll see there's Android Drawable Importer.
In my image, it's already installed, Click Install Plugin and just follow the instructions.
You'll have to restart Android Studio and try to create a new Batch Drawable Import and you'll find it there. ;) Thanks.
While creating a new asset in the drawable folder you need to set the
"Launcher icons"
in the
"Asset Type "
drop down
This will add the images in their original color and will not be greyed out. Also it is possible it adds the images in res/mipmap folder. You can move the images from mipmap folder to anywhere you want.
I Found the proper solution!
You just have to add this code where you created your NavigationView object!
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
//add the line below and your icon will display as your .svg file
navigationView.setItemIconTintList(null);
navigationView.setNavigationItemSelectedListener(this);
When you create a Image Asset as Action bar and Tab icons in the newer version of Android Studio(2.2) it is automatically converted into grey scale,Choose theme from the drop down default is HOLO LIGHT choose custom and you could be able to give the color code,but this works only for sketches kinda images
To get color code

Floating action button android change icon

I followed a template on android studio to create a navigation drawer app. As you know it creates an initial activity with a floating action button and the email icon in it. I just want to change it to a plus sign. Here is the problem. It turns out there is no plus sign available as the ones I can see in every single example ( There is just one I can use but then the plus sign color is green, and I want it white! ).
I followed this steps how to download Material icons , I get the icon ic_plus, and I put every single file in its correspondent folder ( drawables, drawables-hdpi... ).
Problem is when I try to use it here:
The name turns red as it can't find it. As I said, I copied all files one by one to its correspondent drawable folder. I even tried this drawable importer
but the same happen.
What am I missing? And why plus sign icon it is not shipped as default icon, as for example the e-mail icon is, as I can see it in every single app using floating action button? I use Android Studio 1.5. Thank you!
EDITED
Looks like images are correctly placed in correspondent folders because if I try to use it on menu bar, I can find it through #drawables/ . Still don't know why I can't do the same for the floating action button. Ideas?
Put your image in the drawable folder.
Use the design editor and when you click on the FAB scroll down to the src and click that little square button with 3 dots on the right side to pull up all your options. You should be able to search for the name of the icon you uploaded and select it from here.
I tried to type in my file name using text editor and it couldn't find my image either.

Android Development: Unable to create an icon #drawable/ic_action_search

I am new to Android Development. I was just following the basic turorial on developer.android.com to create my first application.
As I was creating the Action BAr, I had to add this Search button to it. I created the menu xml and this is what I had written on it.
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
Now my question is on this part of the XML
android:icon="#drawable/ic_action_search"
I get a compilation error in eclipse, which says,
error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_action_search').
I checked on developer.android.com and also googled it out, but I'm just not able to locate a solution.
I need to solve this problem. As always, I am able to skip this part of the XML and what I get is just plain text "SEARCH", but the icon will definitely look better.
Here is the easy way if you're using Eclipse:
Ctrl+N (emacs keybindings) to open the file wizard
'File | New | Image Asset' in Android Studio
Select Android, "Android Icon Set"
Edit name ic_action_xx, click Next
Clipart, choose the icon you want
Select theme (Holo Light means a light background, Holo Dark means a dark background)
Eclipse will automatically populate the res/drawable-* directories with the new icon, scaled to the directory size. No need to download anything, understand PNG or copy the icon into multiple directories.
I use the file wizard A LOT.
In Android studio:
Right click the Drawable folder > Select New > Image Asset
(Alternatively, click shift, shift and type 'Image Asset")
In the dialog which popped up click 'OK'
From the wizard you can customise the asset you require.
Choose if it's a Notification icon, Action bar icon or launcher icon. You can select icons from clipart, create icon from text or import an image from disk.
The wizard will take care of creating different resolutions for your new image.
You need an image called ic_action_search.png or ic_action_search.gif, for example. Paste this image in every res/drawable folder.
As others have advised, you need to have (put) the icon graphic, "ic_action_search.png" in the correct folder, which is "/res/drawable" You may have to move a graphic file for one or more of the "drawable" subfolders of "/res"
You can find the icon graphics (and others that you will, presumably, need in the future) at, (http://developer.android.com/design/downloads/index.html#action-bar-icon-pack)
Please note: do not use the "Core Icons/unstyled," in the package. Use the "All_Icons/holo_light," (most likely) or "All_icons/holo_dark."
The error means that you don't have an image called ic_action_search in your drawable folder.
You can download an image for search from Android Asset Studio if you like.
I suppose you copy pasted some example code, as other answers says you missed putting drawable into your resources. For testing you might use default android search icon:
android:icon="#android:drawable/ic_menu_search"
I am not sure if it is safe to use it in release apps
First think English is no my main language, i apologize for my typing. Ok let's go to the problem. All this works for me, i hope it works for you. I was following the same instructions from developer.android.com as you, and it didn't say that you have
to put it in both .xml, or i didn't see.
Because is too much stuff and is overwhelming, i know at first but i hope to get used to it soon. Under the folder: res/menu you have two.xml archive one for the main page and the other for the activity. What do you have to do is copy that you wrote to both .xml archive:
Display_message.xml
main.xml
remember the action bar goes along the way with the activity, as many as you have. That means if you add another activity, you have to paste this in the new one in order to void that error. By the way you already have the images int he their respective folder. if not, it going to pop the error again. I hope this was understandable and with sense.
An other way to add a new icon into your project in Android Studio (same as dturvene's in Eclipse)
1. Choose drawable directory; Alt + Insert or File/New...
2. Choose "Image Asset"
3. Select drawable\hdpi as your icon's destination
4. An option window will pop up. Select directory to your icon saved in your PC.
I just found the way to do it so I hope it help.

Categories

Resources