ActionBar Icons having different sizes - java

In my android application, some of the action bar icons are at normal size (like the star in the screenshot) and some are too small (like the browser and the share icon in the screenshot).
All of the Icons are added in the exact same way:
menu.add(getString(R.string.sync)).setIcon(R.drawable.ic_action_sync)
This happens in three of my activities with different icons. The image files are in the correct directories for their density, they are all from the ActionBar Icon Pack and do all look the same size in the directory on the computer.
I use ActionBarSherlock to display the Actionbar on Gingerbread, but it looks exactly the same on ICS/JB, where ActionBarSherlock should use the native ActionBar (so I guess it's not ABSherlock's fault).
I have no idea, what the reason of this could be.

It looks like your icon drawable resources are not the correct size. To fix this, you will need to recreate your icons.
When you do this, be sure to check the Android Design- Iconography page to ensure that you are creating your resources at the right resolution.

Related

icons are showing in full black color in android drawer bar do you know how to fix it?

icons are not showing in activity main drawer they are just showing like full black i dont know why can anyone help me? here is my xml code.
enter image description here
This is because you are using .png files which are not supported by navigation drawer. It only works with .svg or Android Vector Asset.
If you want to use these pictures, you need to convert them to .svg file from here.
How to convert ?
Scroll down and you will something like this ->
Click on Choose a file and pick the image you want.
Once you select, you will see this below it -> (I have used my image)
Click on the Generate button and wait for a while->
Once you see an image in the side, you know that it has been converted ->
Click on the Download SVG button and you will find it in your file explorer.
Once you download them, you can add it to the drawable folder. But make sure that you delete the previous png files.
Tada! Its done! You them in the navigation drawer and you get the icons too!

Libgdx android icon not being applied

I made a game and now I want to change the icon, so I replaced the icons on res/drawable (with the same file name). But when I run the game on my android phone it still installs with the default libgdx icon and not my own icon. Then I tried to change the icon names and also making changes in my manifest file.
<application
android:allowBackup="true"
android:icon="#drawable/loh_icon" //loh_icon.png is my icon name
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
Still the same problem, how can my game still have the default libgdx icon? I deleted those icons and replaced them. I also invalidated my intellij caches and restarted.
If you look in your android/res folder, you'll see 5 different directories starting with drawable. The part after the dash is the screen density.
Inside each folder there is a file called ic_launcher.png with a size for each screen density. This is why by default, you'll find this in your manifest: #drawable/ic_launcher. You'll need to make different resolutions for different densities, and replace them.
You can use this online tool to automatically do it for you: Android Asset Studio.
Make your icon and click the download link. Open the ZIP file, and extract it to your res folder.
You can delete the drawable folders. Go into your manifest, and set your icon to: #mipmap/ic_launcher
In Android Studio just right click over android/res -> new/image asset, on dialog choose icon_laucher and the radiobox for image, there you can select whichever image you want. Android will make all different images for you
Some phones will cache app icons. This means that it might keep showing you the old app icon even after you change it.
Try restarting the phone. Alternatively, you can try changing the theme of the phone if it has such an option (e.g: MIUI)
Android API 26 introduced adaptive icons:
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
libGDX provides new files that handle this. Use the libGDX setup wizard to generate a blank project to see it. The files are stored in:
android/res/drawable-apydpi-v26
You can edit ic_launcher_foreground.xml and ic_launcher.xml to set it up for API 26+ devices.

Drag and Drop in Android Studio layout editor

I have a problem with adding images to my app's layout. I've searched for an answer for a while, but even when doing exactly what friendly people of the internet told me, there is still no success.
images are in PNG format in res/drawable folder.
im trying to drag'n'drop them into the content_*.xml preview.
i can add elements from the palette.
i am using RelativeLayout.
Any idea what may be the cause of this problem?
View of my android studio screen:
You must store your images on Drawables folders not in drawable
-drawable-hdpi,drawable-mdpi,drawable-xhdpi.....
You should drag an ImageView, then add the image with the src param. You can't directly drag and drop images
You can't add elements in "Palette".
RelativeLayout... Okay, whatever layout it's good
UPDATE1
To see the drawable folders you must clic on arrow (see image1) and put on "Project" (image2)
----------> see point 1.
Yes you can drag&drop that elemenst, TextViews, ImageViews, Edittext....
you should drag an ImageView, then add the image with the src param (you can do this in the right menu or with xml)

Designing xml layouts for different screen: Android

I am working on a small app, with 3 buttons on left corner(Vertically) and a edit box which covers rest of the screen.
I want to run this app to be able to work on all screen resolutions.
So I have used Relative layout, linear layout and Android:weight for buttons, which equally share the size of the buttons and works fine.
My Question is am I doing it wrong?
Should we design different layouts for different screens or using same layout out but adding properties like weight and padding is fine??
So, you want a responsive layout for your android app.
Pointing to your question :
[+1] layout -> Relative / Linear (in addition to the relative layout)
property (Buttons) -> Android:weight
is the right thing you are doing for your app.
Alternative:
But if you want a more responsive design then you could follow responsive design techniques by using html5 & css3 media queries etc. . And, could opt for a fluid layout also. By doing this the advantages you will have are:
Won't have a native UI only for android but the same could be used for other platforms (iOS,blackberry etc.) if you require.
The design would be more seamless with the native browser and the widgets won't get obsolete ever in the newer versions of your android
platform also and changes once done would be reflected over the other
platforms too.
More info: MUST READ IF YOU WANT CLEAR UNDERSTANDING OF HOW TO DESIGN FOR ANDROID
http://developer.android.com/design/style/devices-displays.html
http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm
you can see this Supporting Multiple Screens and also Designing for Multiple Screens
To support different screen size you have to implement different layout.
Under res directory you should create these directory:
layout
layout-small
layout-large
layout-xlarge
In each directory you implement your layout. be aware to call all the layouts with the same name.
If you want to support the landscape mode too you have to add:
layout-small-land
layout-large-land
layout-land
When, in Eclipse, you open the layout select the tab called 'Graphical Layout' , you will see how your layout will be displayed. Change the screen size using the options in the upper left side and you can check how it will be displayed in different screen size.
If something is wrong you can open the xml using and correct it.
I've created a small tutorial here Multiple screen support
Hope this help you

android google maps button on popup

Okay. What I have so far is an Android app with a Google map on which I've placed a bunch of icons that, when clicked on, create a popup with some text on it. Is there any way to place a button on that popup? If this is not possible, is there some way to make a button appear when an icon on Google Maps is selected?
In case you're wondering, the code I'm using now looks like this.
itemizedOverlay.addOverlay(new OverlayItem(point, title, text));
//actually a whole bunch of OverlayItems, each with their own location and text
//but this is the general shape of it.
mapOverlays.add(itemizedOverlay);
Edit:
There are different kinds of popups used with different versions (check yourself in the emulator versions) of the GoogleMaps app. The first popup simple displays the title of the location (Android 2.3.3).
The second popup shows the title and arrow indicator. (Android 4.0.3)
Interesting enough: I noticed that both popups are clickable and start another activity that shows details about the location.
The mapviewballon project https://github.com/jgilfelt/android-mapviewballoons/ allows you to use your own custom layout for these popup.
I did not test with buttons on it but I do not see why I would not work.
The example projects shows the following types of popup balloons.
Here is another project that creates a custom popup balloon. The project can be downloaded at the end of the article.

Categories