Android : Deal With Multiple Screensizes + Dynamic Controls In Droid?
Apr 23, 2010
I am learning how to program on Android phone. However I am unsure how to make my application work for the different screen sizes and resolutions.
I read the tutorial on the android site and still unsure how to do it.
First I know there are different files so could make a layout for each of the sizes but my problem is most of the screen needs to be dynamically created so there would not be much to put in these files.
So I am not sure how to android to re size dynamic controls based on the screen size.
I have also read it is bad practice to make controls in anything but the xml file as it separates view logic and programming logic. However they never talk about if you need to make these controls dynamically what you should do.
So is there some other way to do it that is considered good practice?
Edit
I get this error when I try to run the switcher application.
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: Error type 2
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: Error: Unable to connect to activity manager; is the system running?
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: usage: am [start|broadcast|instrument|profile]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am start [-D] INTENT
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am broadcast INTENT
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-w] <COMPONENT>
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am profile <PROCESS> [start <PROF_FILE>|stop]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: INTENT is described with:
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-c <CATEGORY> [-c <CATEGORY>] ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-n <COMPONENT>] [-f <FLAGS>] [<URI>]
To your question: It's dynamic because
the buttons in my example grow and
shrink depending on one of the 3
possibles sizes, because they use
scaled pixel (You probably know that
you don't have to deal with screen
sizes itself). So a scaled pixel
compared to a real a pixel has a size
of 0.75px, 1.0px or 1.5px. Android
automatically and dynamically adjusts
it to the actual size. So you don't
have to care about this in your code.
So if I use scaled pixels then I don't have to worry about different screen sizes?
At the moment I don't know an example
except in games where you have to deal
with "real" pixel. But if you want use
it, multiply it with the value of the
current density. This is your "ratio".
I don't have the example with the ball
anymore but I have another which uses
the same technics. You can run it on
different screen sizes and you will
see that the buttons will always fit
into the layout. You could use the
same technics for your intents. In
this example you can scroll with the
"Scrn" buttons from one view to
another of 4 views. (At the moment
they all have a black background so
you don't see that they are different
views). The "Enter" button exits the
test. It's an Eclipse project. You can
download
So if I want to deal with ratio then I use real pixels and not scaled pixels? What advantage does this give me?
will scaled pixels work with changing from portrait to landscape( ie will it fill up the new found space)?
Finally should I make the controls now through code or is there another way? As I said I am getting data from a webservice that must look like this
checkbox label label
It can be one record or 10,000 records I don't know so these have to be appended to something that is like a window panel( the controls in there get a scroll bar).
View 3 Replies
Jan 23, 2010
I am trying to create a screen with some dynamic controls, well radio buttons to be precise purely for learning purposes. I have managed to add the radio button by referencing the radio group in the main.xml file.
View 2 Replies
View Related
Jun 24, 2010
I've got a query, (I'm using rawQuery())
SELECT * FROM <table>
I'm then storing what it returns using a cursor. From their what I want to do is, start at the first row so.. cursor.moveToFirst() then take each column , column by column and store its particular value in a variable. I then want to move onto the next row and do the same. So I guess my question is How would I get cursor to deal with multiple columns?
View 2 Replies
View Related
Jun 9, 2010
I have an activity with two edittext controls. I am calling the requestFocus on the second edittext field since by default the focus goes to the first edittext control. The focus appears to be in the second edittext field (the second one gets the highlighted border), but if we try to enter any characters using the hardware keyboard the text appears in the first edittext control.
View 1 Replies
View Related
Aug 15, 2010
I am working on an Android project where a group of buttons needs to show on the bottom of every screen (activity) in the application. The group of buttons are basically a navigation bar. I want to know the best way to do this without creating new buttons for every activity. I have been around programming (C++/C#) for many years but am pretty new to Android and Java so if someone can point me in a general direction.
View 2 Replies
View Related
Aug 20, 2010
I would like to make a single Android app for multiple Android versions (possibly every one of them)
My problem is that I want to check what is the version of Android the app is currently running on, and dynamically load a class which is version dependent. This part should be ok.
I just wonder how I can achieve that without compilation errors in my Eclipse project. I mean, the project is configured for a particular target (1.5, 2.1 ...), so if a class in my project is not compatible wich the selected target, it will result in errors.
Is there a way to export this classes even if they are not fit for the platform (I thought about a separated lib, but then again : how to compile theses classes into a lib without compilation pbs?) ? This should be ok since they won't be loaded until I ask them to after having checked Android version.
View 2 Replies
View Related
Nov 12, 2009
We have uploaded a new version of our app where we added the following to the manifest: <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" /> However, we are receiving complaints that users cannot find the app on the market using their HTC Tattoo and HTC Dragon phones. Any ideas what we are doing wrong, and is there a way for the developers to test if the app is visible on the market?
View 1 Replies
View Related
Dec 12, 2009
I am trying to develop a Android Google Map application, which is basically Gmap with my own marker geo layer. Since android.com is banned in China, I have to search support from Google user groups. I have no idea which groups I should call for help, android group or google map group. Anyway here is my questions:
I am working on Android SDk1.5. I want to reproduce the floating buttons presented in android Google map, which stands for three buttons: ZoomControl (left), FocusChange (middle), and ListControl (right). (Pls check ref1. ) I checked some open source projects, if designer can place these controls in the layout.xml with relative layout, to place them over (on the top of) the mapview. It may solve some problem, however in the SDK1.5' add-on gmap jar, the getZoomControl is discarded. I can only setBuiltInZoomControl(true) to enable the builtin zoomcontrol. By default, the "BuiltIn" Zoom Control is placed at Bottom/Center. (Pls check ref 2.) I have no idea how to relocate the "BuiltIn" Zoom Control to the left as native GMAP does.
So: How to relocate the BuiltIn Zoom Control ? How to add addtional custom control (buttons/overlays) with BuiltInZoomControl ? What functions should be overriden for the detail implementaiton, Such as synhcorization with the visibility? I am appreciated if the answer can be offered with code snippet or references to any internet site.
Ref: 1) http://www.ennovation.org/pix/transit-android-google-maps.png 2) http://www.ennovation.org/pix/device005.png
View 2 Replies
View Related
Jul 25, 2010
I'm all new to this android stuff and i was wondering what the big deal of root is? like what can you do with root that you cant do before? Please don't comment if you have something bad to say as you were too once as new as me.
View 3 Replies
View Related
Feb 5, 2010
What's the deal with the Flickr integration?I thought I would transition over from Photobucket because it looked like it might make it easier to access and share photos.So I find out that I need a YahooID to sign up for Flickr.Why not something with Google (Picasa)?
View 2 Replies
View Related
Apr 10, 2010
First of all, I'm a very happy Eris user. I've had the phone since January and have just decided to "put up with" the fact the vibration is too weak. But its starting to get rediculous. I miss calls, texts and emails constantly with this phone! And just yesterday, my Boss actually made a comment to me about it (something like "you need to start answering you damn phone!"). I had a BB for 5 years leading up to my getting the Eris in January and rarely missed a call or message.
I have Smart Vibrate loaded and have programmed distinct patterns, but it's not helping. If somebody doesn't have a good idea or remedy for this, I might be forced to go back to BB.
I've read posts like this before and everybody just seems to deal with this, but please tell me somebody has a trick they can share
View 18 Replies
View Related
Jun 11, 2010
About the Eris. On version 2.1 does Beautiful Widgets (the app) show under "data" on your SD card? Should it? If it doesn't belong there should and I delete BW - will the clock/weather on the home screen still work? I expect the HTC / Android clock weather deal is a widget vs an app? Or is it an app and what is it called?'
View 6 Replies
View Related
Aug 15, 2010
holy cow, since 2.2, my battery drains in like 4 hours. even in standby. is there some setting i should turn off? whats the deal?
View 9 Replies
View Related
Nov 29, 2010
No calDav support (and no, the free app Calendar syncing does not work with my company's iCal server) is a deal breaker for me, unless one of you guys can point me in the right direction, my iPhone 4 will have to come out of the drawer.
View 3 Replies
View Related
Jun 12, 2010
I want to add a non-native shared library to Android so every application on the device would be able to use it. I mean using packaged classes just like a core library as if they were present in the application itself. I studied Android source code to figure out a way to add a new path to the application ClassLoader and found out that it is created during startup and there's no way to change the paths later. I can use my own ClassLoader, but all I will get after loading a class will be a reference to a Class object. This way I will be bound to work through reflection mechanism, which is slower than the native execution system Is there any way to organise a shared library on Android?
View 2 Replies
View Related
Apr 5, 2010
I am following this tutorial http://developer.android.com/intl/de/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually like to add you know some controls to these tabs like textboxes(text edit).
How do I do this? I go to my mail.xml using eclipse as my ide and go to layout view and I now get a NullPointerException so I can't even drag stuff onto the layout anymore.
View 4 Replies
View Related
Apr 25, 2010
I'm stuck on a problem and if possible I will need help from the community. I'm not looking for a ready-made solution, but something which would help me to produce the result.
I'm looking for a way to produce a dynamic activity based on a JSONArray object.
Here an example of a JSONArray object:
[ { "name": "my checkbox name",
"type": "checkbox",
"value": "one,two,three"
}
{ "name": "my edit text",
"type": "text",
"value": ""}...]
This JSONArray could be totally random. It could have 2 text views, 3 select menus, 1 text view and so on.
The goal is to iterate over this JSONArray and create the appropriate elements within my android code.
To produce the result I've thought of a simple switch which would render one by one my different JSONArray to an android widget.
But after that how could I have access of every property of every widget rendered?
Edit: I need as well to assign an event listener on some widget as taking the GPS coordinated...
View 1 Replies
View Related
May 10, 2010
I am trying to develop an app and I want it to bring in data from a mySQL database. But from some reading I have done on different sites, I am realizing that it is probably not going to happen. But I am curious to know, how do apps like PhoneFlix and others view that dynamic data on the application? Does it somehow just bring it in through http? If so, how would I go about doing that? Does anyone know of any good sites that will point me in the right direction?
View 1 Replies
View Related
Jun 25, 2010
I am new to Android. I need to view one text on the screen. After thread sleep time I need to add another text on the screen. I have to show the text adding but my code display after all the append operation. How to show adding text one by one? code...
View 1 Replies
View Related
Jun 25, 2009
I would like to create a custom Control in my Android App. It will be a circular control with some smaller moveable circles that will indicate a specific value.
Is there a way to realize this?
Are there at least some nice Tutorials where i can read how to create a custom control?
View 1 Replies
View Related
Dec 23, 2009
Is it somehow possible that instead of:
Button btnNextWord = (Button) this.findViewById(R.id.btnNextWord);
Eclipse automatically generates for me something like:
Button btnNextWord = this.btnNextWord;
or
Button btnNextWord = R.id.getBtnNextWord(this);?
View 1 Replies
View Related
May 14, 2010
I want to zoom text that is displayed at center of screen as per user choice. How can I achieve this ? Using pinch multitouch cannot be tested on emulator and I want something that I can test on Android emulator.
Can I use zoom in and out controls to control only text view for my layout ?Or Can I use webview to contain a text as webview has default zoom in out buttons ?
View 1 Replies
View Related
May 17, 2010
I am developing an application, and I want to make it work on different resolutions and different densities. My question is how to position the controls through code such a way that it works on all resolutions.
View 1 Replies
View Related
Jul 7, 2010
I try to add a table layout from Java code. When there are two fields in a tablerow it displays the first field only. How to display the entire row with all fields?
code... How to do this?
View 1 Replies
View Related
Jul 25, 2010
OK, So I want to set the background to a transparent image and change the color of the background on an event firing. I can set the background image to a resource in an xml file, and I can also change the color of a TextView on event firing, but for some reason I can't do both at the same time. Do I need to create a drawable or something? Also, how do I reference the top level LinearLayout. I'm programming using eclipse JEE Galileo with the ADT Plugin and the android sdk. O.S. android 2.1-update1 (eclair). My friend can do it in actionscript and I have to do it in java to beat him lol.
View 1 Replies
View Related
May 23, 2010
You can move between fields with the track ball.
As the title says I am looking forward to know how to I set the tabbing order of controls in Android?
View 1 Replies
View Related
Sep 10, 2010
I have a custom list adapter contains a layout with controls in it. I was wondering how I can get each individual controls id? I am planning on changing the color of some textviews. code...
View 1 Replies
View Related
Apr 20, 2010
How can i make a dynamic flipping screen(like that of iPhone) in Android
I am parsing data through the web service. I want the flipping horizontally rather than vertically. Here is a tutorial where ViewFlipper is used but it is for static data.
Suppose we have 2 activities with their respective xml files: Splash Activity ->splash.xml Menu activity ->menu.xml Now how we can flip between these 2 activities? That is from splash to menu and vice versa.
View 4 Replies
View Related
Apr 12, 2010
Strangely I find no support for Midi in Android.
The only thing that comes close is the Jetplayer, but this only takes a existing .jet file.
I want to dynamically generate a midi file with some intervals and play it.
I even thought about just manually creating a .jet file with a tone and then transposing it with the jet player, but it limits the transposing to -12, +12. Which is not so good for me.
There also is a ToneGenerator on Android, but it's limited to predefined tones with no way to transpose.
Does someone know how to achieve midi generation and playback on Android?
View 2 Replies
View Related
Sep 18, 2010
I am able to play a video using VideoView in combination with MediaController. The problem when I started my activity , a bar appears below with media controllers play,pause,rewind ,progress bar representing video. But it disappears after displaying 1 second. Then I how can I make this media Controller bar with controls to display as long as my video plays so that I can pause,rewind my video.
View 1 Replies
View Related