I am developing an Android application that uses a RatingBar, with 5 stars.
I have a HTC Wildfire, and RatingBar works very good. I have a layout for this screen.
However, I am testing in a HTC desire and it appears 4 stars, and it seems RatingBar doesn't work well.
I found a temp solution, adding this to the Manifest:
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="7" />
And RatingBar works perfect, but another layout of an Activity looks now bad.
And in Wildfire, my layouts looks now bad too...
How can I do? Is it a bug of Ratingbar?
The problem has bothered me....setting minSdkVersion="4" is effect.But another views may looks bad.
I’ve just spent far too long wondering why the RatingBar views in my Android XML layouts look different on the emulators, HTC Hero and HTC Desire. Small style rating bars seemed to have no concept of their actual size and the large rating bars for user interaction were clipped and falling of the edge of the layouts.
The answer is that the RatingBar view doesn’t scale properly on high density screens if you have the build target set to Android 1.5. The fix is to target API level 4, add screen support declaration to the manifest and then be careful not to break anything for the 1/3 of users still on Android 1.5.
Try setting the layout_hight of rating bar bigger:
android:layout_height="20dp"
See:
http://blog.csdn.net/prince58/article/details/6371389
Related
I've small problem - I've and app (home screen widget) for android ICS and higher. But different phones with different OS version (4.0.4, 4.1.2, 4.2, etc) and also different brands (Samsung, HTC, LG, ...) makes my app look diferent.
Ok, it doesn't happens always, but on some phones just Android adds automatic margins to my own - and on some not!!! How is this possible, and how to avoid this? Looks like every brand does it in their own way - which is fine for them, but bad for me :)
EDIT:
I use dp, not px. The main problem is not in dp/px nor in portrait/landscape changes. Main problem is, that for example on phone1 my widget has NO margins (it's like sticked to screen borders) and on other phones it has automatic margins like it should. When I add my own margin to widget provider, it has this margins on phone 1, but on other phones it has (my margins + automatic margins). Hope, now it's clear :)
Welcome to Reality show, when the Android it isn't platform independent, either Java it isn't.
For this reason a single android layout.xml should use elements which are doing layout acceptable in all targeted devices. The screen ratio differs, the dpi differs the resolution differs... As best practice:
use dp size instead of pixels
do different layout for portait and landscape case
have multiple folders based on screen size ( and different layout)
I hope it helps!
well, to close this answer - it looks like there is really no option to have same margin on all devices - as different devices uses different home screen implementation. I can't do anything with that...Closed.
I have a widget which was made for Android 2.3.
It has these dimensions:
android:minHeight="76dip"
android:minWidth="146dip"
The problem is that Google has changed the height of a cell in Jelly Bean or even in ICS.
A cell is now 40dp and 2 cells 110dp. This makes my widget streched to 110dp. This looks very ugly as it is streched a lot.
If I increase the fontsize on my widget and the spaces, I can make it fit in the 110dp height. But then it will look ugly on Android 2.3.
I am wondering how I can adapt the widget to look nice on JB AND on Android 2.3. Is there a recommended guide?
Every device may have a different grid size. The only foolproof solution is to use flexible layouts, 9-patch drawables, etc.
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.
I have a small Android app which works fine on resolutions up to WVGA (480x800), however beyond this the layouts don't scale (for instance for the Galaxy TAB 1024x600) but appear in the top in the middle (with black borders down sides and at bottom). The layouts look fine in Eclipse at these resolutions.
What Am I doing wrong?
Am I missing something in the manifest? Do I need to supply high resolution resources?
Try putting this in your manifest.
<supports-screens android:xlargeScreens="true" />
http://developer.android.com/guide/topics/manifest/supports-screens-element.html#xlarge
putting
<uses-sdk android:minSdkVersion="4" />
In the correct place in my manifest solved the issue. For some reason I had placed it under <application>.
I've created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units is not enough if you want your app to fit on all devices and tablets, since there's 4 different "density-buckets". The tool will allow your layouts to be converted into fitting these density buckets.
It will also explain in further detail how to make flexible view components.
I have a problem with missing pixels on QVGA screen on Android (all versions including 2.2). The original problem was with LinearLayout and margin="1px". It was OK on the normal screen but on QVGA there was sometimes no space between GUI controls, like if margin="0px" and not 1px. So I tried to make the example simple (to be sure that it is not a LinearLayout bug), I have just put transparent (height = 10px) and white (height = 1px) images into ImageViews into the main screen. 25% of the white images are not shown on the QVGA screen. The behaviour on the normal screen is OK. The screenshots are from the emulator but the problem exists on real devices too.
See screenshots on my web page.
Is it an Android bug? Can I do anything with it? Note that my original problem was with LinearLayout and margin="1px". Is there something like margin="1px_that_is_not_hidden"? (pt, dp, dip, ... don't seem to be solution)
Many thanks for a reply.
You are probably in a compatibility mode, where Android is attempting to scale your dimensions for you, rather than thinking that you know what you're doing. It's been ages since I targeted a QVGA device, so I forget the precise details. However, I recommend you read the multiple-screen-size instructions. In particular, you probably need to set android:anyDensity="true" in your <supports-screens> element.