I`m developing an App using ActionBarSherlock
One of the items in the menu is a rectangular image. See it`s xml:
<item
android:id="#+id/kapturar_action"
android:showAsAction="always"
android:icon="#drawable/camera_action_icon"
android:title="#string/kapturar" />
<item
So far so good.
The problem is that the SDK 4.3 appears to accept only square images (This is my supposition, i`m not sure of that) and the icon shows in a strange fashion preserving what appears to be a "max width" property.
See the printscreens
Android 2.2 - Simulator:
Android 4.1.2 - Samsung Galaxy S3 Mini:
Android 4.3 - Nexus 4:
I double checked the drawables and I think that everything is right. I have defined the MDPI, HDPI and XHDPI images.
Can anybody affirm that is impossible to use rectangular drawables in the menu`s item? Is there a way to fix the problem in the Android 4.3 preserving the backward-compatible?
Action Bar Sherlock is now deprecated as Google released their own Action Bar compatibility library.
I strongly recommend to switch to that official library, I guess/hope your problem won't appear there.
You can simply use compatibility version of ActionBar. This is not very good answer but it will help you.
To make it just comment line
registerImplementation(ActionBarSherlockNative.class);
In ActionBarSherlock class.
Moreover after this you can edit sources, resources in ActionBarSherlock and they will look the same on Android 2.3 and Android 4.0+ devices.
Try to put your drawable into another folder. I mean if it is in drawable-xhdpi folder put it to drawable-hdpi (or other).
Sometimes it solves the problem with resizing images from resources
Related
I have a very simple activity showing an image:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/my_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/activation_background" />
</RelativeLayout>
my_image.png is only in /res/drawable-xhdpi/ and it is working fine for all the phones I've tried so far, except the Galaxy S5 with Lollipop (it is working on 4.4). On this specific phone and version, the ImageView shows instead a kind of default Android icon that is even not in my project.
To fix it, I need to put my_image.png in /res/drawable-xxhdpi/. But I don't understand this behavior. It is working fine on the Nexus 6 without the need to do that. Is it a known issue of the 5.0 version of the S5? Is there another way to do it rather than moving the image to drawable-xxhdpi?
Well, you should be creating drawables for each size screen. Android Studio has a tool to do this for you - right click on drawable and select new -> image asset
Otherwise, in Lollipop and up I believe vector graphics are supported - check here:
https://developer.android.com/training/material/drawables.html
If you are able to provide the image at the xxhdpi resolution you definitely should add it. It is best practice to have all your graphics defined in mdpi, hdpi, xhdpi, and xxhdpi folders.
Otherwise a workaround would be to simply make a copy of the image in the xhdpi folder and add it to the xxhdpi folder. That way phones at xxhdpi will still have a drawable resource to load.
Well the solution to my problem is a bit odd. I fixed it by simply renaming the drawable activation_bg to something_activation_bg. Please note that anything other than activation_bg was working, except activation_background which led to the same issue.
I don't know why this is an issue specifically on the Lollipop version of the Galaxy S5. There shouldn't be any conflicts with anything external to the app so it is really odd.
I use the ActionBar provided by android.support.v4 and until now, works really good. Now I install my app in android 4.3 and stop works.
It seems that in version 4.3, Android leaves the fixed width of the icon, and in addition, includes a padding which further reduces the icon size.
I use this code to make each Action:
android.support.v4.view.MenuItemCompat.setShowAsAction(menu.add(0, 1003, 2, R.string.no_local) .setIcon(R.drawable.nolocal), MenuItem.SHOW_AS_ACTION_ALWAYS);
Android 4.0.4
Android 4.3
What I need change to make my action bar in Android 4.3 looks like in Android 4.0.4?
I change the icon of my ActionBar to 32x32 px I said in:
http://www.creativefreedom.co.uk/icon-designers-blog/android-4-1-icon-size-guide-made-simple/
I have developed a UI for android 2.3. The UI contains a list, and some icons on bottom of the screen.
I have used #android:style/Theme.Holo.Light in <application/> tag.
I have tested this app on Samsung galaxy nexus (android 2.3) and galaxy nexus (android 4.0). It works very well.
But when I run this app on Motorola Razor XT910 (android 2.3), if the list contains only few elements, i.e. it does not cover the entire screen area (i.e. screen area above the bottom icons), the empty part appears in grey color. I have also used the background tag for layout set as white color. The UI on Moto looks like this:
Please suggest me how to make this grey area as white background. I have tried alot but couldn't find the solution.
Thank you.
Instead of making its height as wrap_content add the below attribute to your list view.
The problem is android:overScrollFooter. Motorola has a default one set and it causes sadness. To get rid of it, set android:overScrollFooter="#null" in your ListView.
I too faced the same problem in Motorola Devices
Defy MB526 OS 2.3.4
Droidx OS 2.3.4
This problem occurs on motorola devices using android 2.3. The simplest fix is to set the listview height to wrap_content. More on the issue here.. Moto Listview
Set background color of your main Layout as White.It will work fine
I have an app, which provides a switchable set of night mode (red) controls using a custom Theme. The controls are in the Shared Preferences view. I have copied and colored all of the necessary images for my controls from Android git sources' hdpi and mdpi folders. The red theme works perfectly fine on the 160 dpi screen (480x800 Android 3.2), but on the 240 dpi one (480x854 Android 2.1) custom check boxes and radios are invisible, they do not occupy any space on the line with label either. Though the drop down list control on a simple linear view seems to be shown perfectly fine. The only difference I can see is that the later one has .9.png images.
What is wrong and how to fix that?
HURRAY! Found the solution by an accident. I have added a hidden checkbox item to one of the first views of my application, and all of the styled checkboxes magically appeared as they should be in every other view! I believe it's a bug in the 2.1 version of Android. I saw something like that mentioned once while googling for the problem here. It might be irrelevant though.
in my app, I have buttons with icons. The icons are provided as PNG images in the three densities in drawable-ldpi-v4/, drawable/ and drawable-hdpi-v4/. Here's a sample:
Each icon is displayed in an ImageButton:
<ImageButton style="#style/Shortcut" android:id="#+id/open_button"
android:src="#drawable/shortcut_open" android:layout_marginRight="4dp"/>
Where the Shortcut style is:
<style name="Shortcut">
<item name="android:layout_width">65dp</item>
<item name="android:layout_height">45dp</item>
<item name="android:scaleType">center</item>
<item name="android:background">#drawable/shortcut_background</item>
</style>
However, on certain devices/platform versions, certain icons get altered, blurred or something. I'm not sure that it's scaling, it's more like a rendering bug I think. I have tried to disable anti aliasing on the BitmapDrawable, but that didn't help.
As shown on the image below, on Android 2.1 LDPI, one icon gets broken/cropped, and on both Android 1.6 MDPI and Android 2.1 HDPI an extra line seems to be randomly added at the bottom of the icon (look closely).
In the manifest, I have an empty <supports-screens /> as recommended in the docs about supporting multiple screens in legacy apps. Adding anyDensity="true" doesn't help.
Apparently, as of Froyo, things get better as you can see on the image above. But how can I solve this on Android <= 2.1?
I think you should not use explicit sizes (even when expressed as dip) for the buttons, but let the system do it for you.
Use
<ImageButton android:id="#+id/SpeakButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Also it may be that you are falling into the "dip" vs. "dp" trap that others have reported, where documentation says that they are synonymous, but using "dip" made stuff work as intended.
Not sure if this is the case but you can check if you are not running into the bugs mentioned in this Google I/O talk. I still have to wrap my head around it but I think it's worth having a look if you are targeting platforms from 1.5 to 2.0.