ActionBarSherlock leads to icons get stretched - android

We have started integrating ActionBarSherlock into our app. Everything looks great, it's a really great lib, that gets in easily. But, there's one issue we don't know how to solve:
Some of the icons on some pages for larger screens get stretched. Has anybody had such problem?
Upd. 1.: Device that has icons stretched is running on Android 4.2.2 (it's Nexus 7 actually). All ok on a smaller screen like HTC Desire (2.3.3).
Upd. 2.: As the example of what is happening: there's an icon of a size of 48x52 pixels. It is in the "drawable" folder. It is used as the background for a Button widget. Before the update the app used this icon as is, i.e., it looked like 48x52. Now, looking at the element borders it looks as if the app is stretching the widget's width to be 52x52 or even wider, keeping the height same. layout_width, layout_height are set to "wrap_content"

Ok, using this answer I managed to fix -
changed all the Buttons to ImageButtons
all the android:background-s to android:src-es
android:background-s set to 'transparent'
But! I don't know why it happened and why it worked! Any clues? Thank you!

Related

layout on android studio preview doesn't look the same when running the app on the phone

im developing an android app on android studio, when i run my app the layout looks a bit different from the preview as well as on other phones,
for example: the buttons are in different order (from right to left instead from left to right) or other changes similar to this.
as well as on some phones the layout doesn't fit perfectly on the screen for example: the buttons on the sides of the screen appear to be cut out.
how can i fix it so the app will look the same with every phone and not only some of them?
About the Right-to-left/ Left-to-right, you can choose the globe icon in the preview options bar frame and then choose Preview Right-to-Left Layout option. This will "fix" the buttons order in preview.
About the buttons that appear to be cut out - make sure you use dp units instead of pixels. You can read more about it here:
http://developer.android.com/guide/practices/screens_support.html
Make sure you check if you have used the constraints on your components properly. Usually that's what makes the layout messy after running the app on your phone/emulator, even tho it looks perfect on your XML file.

how to make app stretch to all phones android studio

so I'm making a really simple app that just shows some buttons and images,
it looks great on the simulator (because I guess that's the resolution I've been working on ...)
but when I try to build it to my phone it looks differently (the buttons are more stretched out and there is allot more background space in between the buttons and the end of the screen,
I guess it's something that's suppose to be simple but how to I make my app "zoom stretch" to the phone content it's going to be on, meaning it will look the same on any phone and if necessary will stretch the image a bit to fit the screen ?
Thx
In your XML, its important to not use specific(dp,px,etc.) sizes for laying buttons/text boxes/etc. out. For example, for a button thats on the page, use a "layout_width" of "match_parent" and add padding (if necessary from there). This will allow your button to stretch properly without having that extra whitespace.

Iconfont charachterspace collapses in Android (Fontastic)

I’ve used Fontastic.me to create an iconfont. It works great except in the native browser of Android 4.2.2 and 4.3 (eg: modern Samsung tablets).
In these browsers, the characters of the entire font have no width. This occurs with every font made with Fontastic.me (even the fonts it supplies itself). This is a major problem when centering the icons (horizontally).
I've set up a webpage to test it: http://ajuin2013.boondoggle.eu/fontastic-streamlineicons/icons-reference.html. The pink color shows the width of the character.
The following screenshot compares the normal behaviour with the AndroidBrowser-behaviour :
http://ajuin2013.boondoggle.eu/fontastic-streamlineicons/fontastic.png
I’m sure it’s because of the Fontastic, because when i use Icomoon as fontgenerator, the problem doesn’t occur. I've also notified the owner but he says he can't look into it because he doesn't now how to install an Android Emulator on his Mac.
Does anyone has a clue to what's happening here? What causes the character-space to collapse?
I had the same problem yesterday. I resolved it with a little bit of a work around. Like you said, when you want to center the icon with text-align:center; it ends up more to the right. If you put it to the left, it aligns left as intended. So I made the speudo element exactly the same width as the icon and centered the speudo element with margin: 0 auto; In that case you can leave the text-align to the left.
I know it's not the perfect solution, but for now it works for me and maybe also for you.
I had the same problem and resolved it by using icomoon.

Can't set background for TabWidget android

I searched a lot but could not find specific solution for my problem. I am posting a screen shot where you can see a tab widget. Also there is an exclamation mark there don't know why! You can see on the right bottom corner there is Background set to drawable. I have put the same named drawable into x,m,l,s, dpi folders. Also you can see in the Screen shot that there is API 8 used. Now the problem that I am facing is I can see the background set for 4.0 but not for 2.2! I have used setBackgroundResource also in class file, I tried to set alpha 0 for this tabwidget also. But don't know why its not taking my image as its Bg for API 8!! Thanks all would appreciate any relevant help.
i did try it like you and same result.. with normal tabhost on api 8.
But finally i did download :
http://code.google.com/p/android-custom-tabs/downloads/detail?name=customized-tabs.zip&can=2&q=
And as sample edit tab_bg_unselected.xml change it to transparent instead of that gradient.
put a solid element with android:color #android:color/transparent and it would be transparent after.
Then set a backgroundimage to the tabhost and its working nice.
Author article is : http://joshclemm.com/blog/?p=136
I think this is a very good solution and you could even make greater customization with that one.
Its a nice workarround, hope you could like it :)
Here a screenshot on a real 2.2.1 Motorola Milestone
Note : Did even verify it on latest Nexus 7 4.3 tablet and S2 4.1.2

ImageButton does not display a particular drawable

This is rather a funny problem I have ever come across,
I have a table layout with 9 image buttons, 3 per row. Every ImageButton has a different image associated with it. I have set the background of the image button to transparent (#00000000). Now here is where the funny stuff happens, One of the images doesn't show up on the emulator (Gingerbread) as well as a device running Froyo. The layout editor shows all the images in place.
Here are some more stuff:
I used a RelativeLayout instead of a TableLayout, the same issue persists.
I changed the position of the image (used it on different buttons) and still it doesn't show up.
When I use a different image they show up, but when I use this particular image it won't.
All images have the same resolution (90x72) and density (72ppi)
All the images are in the the drawable-mdpi folder.
Any pointers?
EDIT
Turned out to be a bug and this issue has been resolved. Please check this link.
Do you still have the problem. I had a similar bug - a particular drawable was not being displayed, no matter in what `ImageView`.
Is it the case that your image is the first (alphabetically) in the drawable folder? For some strange reason there is a problem with the first drawable, I've solved my problem by adding a dummy drawable in first place. Still I'm very curious where the actual problem is.
Hope that helps! And I'm looking forward for any further explanations :)
I can confirm adding a dummy image which displays first alphabetically is a fix.
I had an image (titled about.png so of course near the top of the drawable folder) which was not displaying when the test device used was mdpi.
In my case, though, the image was not the first in the directory. I actually had an image which alphabetically displayed first called about_icon.png - which oddly was displaying fine. Additionally, the hdpi version of the image was displaying fine within an hdpi device.
I added a dummy placeholder image called "aaaa.png" and now the mdpi about image displays fine in device.
Very strange, and honestly a pretty lousy bug.
Try to use android:src="#drawable/my_resource", instead of app:srcCompat="#drawable/my_resource".
This post is fairly old however I was experiencing a similar issue. Running 4.4.2 my imagebutton's would show some images correctly however others it would change. For example my white "ic_camera.png" would look like this....
What appeared to randomly turn images into their dark counter part.(I double and tripple checked that I put the right color in) All images came from the Android Icon pack. I tried deleting and copying back all images multiple times to no avail. Finally I just changed the naming convention, dropping all of the "ic" and "_" so that the images where all simple words and lower case. ie... "camera.png", "upload.png", and "newimage.png"
BINGO!
Very strange but a simple fix. Hope this helps someone else!
Cheers!
For anyone coming to this question and the answer does not work, your image size might not cater to the devices target size... click here to get the right sizes.
For me it was a different issue. The images did show on nexus4 and nexus5 but not nexus3. I scaled down the images from 2000px width to 1000px width and worked like a charm.
When you do it in DESIGN PANEL you get something like this:
<ImageButton
android:id="#+id/translate_button"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:srcCompat="#drawable/translate_button"/>
Change the last line manually into:
<ImageButton
android:id="#+id/translate_button"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/translate_button"/>
It worked for me.

Categories

Resources