fragments on the 7 inches tablet - android

Can I use android fragments with 2 columns layout on the 7 inches android tablet? It has got 800 x 480 resolution.
When I use it on my smartphone with resolution 480 x 800, it shows as one column layout.

Yes.
Since the screen size of smartphone is small, the fragments are shown as a separate activity whereas in tablet it is shown in 2 column layout.
Moreover, it is not related to screen resolution
Refer this: http://developer.android.com/guide/practices/tablets-and-handsets.html

Related

Sizing widget equally (xml approach only)

I have one problem with UI widget sizing, see 2 devices below as an example,
1.) Samsung Galaxy Tab 2 7"
- Pixels : 1024x600 (mdpi)
- DPI : 160
- Density : 1.0
2.) Samsung Nexus 10 2013
- Pixels : 2560x1600 (xhdpi)
- DPI : 320
- Density : 2.0
If I place a widget with 50dp, by using px = dp (DPI / 160), it would be 50px for Tab 7" and 100px for Nexus 10. But in term of percentage, 50px is equal to 4.88% of screen width on Tab 7" while 100px is 3.9% of screen width on Nexus 10.
But, I need this widget to appear with same width percentage. So, I came up with 2 options.
A. Calculate at run time by getting the physical pixels and apply percentage, then resize the widget.
B. Calculate size and place in < dimen > in different xml file (sw600dp and sw700dp for my case).
As of now, I'm using option A to calculate size and set at runtime. It works well but I'm afraid that the calculation could affect the performance. If I choose option B, I will need to calculate size for every widget in every screen (50dp for Tab 7" and 62.5dp for Nexus 10 will result as 4.8% on both). But, if I want to change this value later or some manufacturer introduce new device with difference DPI or pixels (imagine, 7" tablet with hdpi resolution, 1.5 density, 240 DPI), I will have to redo all the calculation and update or provide new xml again.
So, my question is, is there an option C which will not slow down the performance and not taking a lot of manual calculation into account in future?
P.S. Sorry, I forgot to mentioned that I also using weight approach with my static widgets already, but my question is about dynamic-generate widget. For example,
a gridlayout that showing 5 columns on Landscape Tablet
a scrollview to show 4 rows per page on Phone
an ImageView with 5% padding
an ImageView with an aspect ratio on every device.
dp are almost equal on all devices in size, not in screen %
If you need same screen % then just get display size & calculate desired % of it. Then dynamically apply to your widget

How do i add new android screen for UI testing in Eclipse

Currently i have the following screen definition listed by Eclipse. I would like to add at least 2 more screens so that i don't have to run it on the actual device for every time i make a small changes to the layout.
I would like to add the following two screens:
480 x 800 pixels, 4.3 inches (~217 ppi pixel density)
1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density)
Could anyone tell me how to do this. Thanks.
select Preview All Screens so you can show many layouts in screen
You can create new virtual device from android virtual device manager -> device definitions -> new device..

specific 4 inch drawable layout?

I want to design a specific layout for galaxy S3 mini or any device with 4 inch screen size, now I don't want to use normal-layout because what looks perfect in other devices in normal-layout looks messy in 4 inch devices, I tried to do a layout for 480 x 800 like layout-w480dp-h800dp but it didn't work so what specific layout can I use?
Thanks in advance.

Android, mdpi density but different screens

I am working on an application that will run on multiple devices. I have three devices for testing.
HTC Desire S -- 480 x 800 pixels, 3.7 inches (~252 ppi pixel density)
Samsung P6200 Galaxy Tab 7.0 Plus -- 600 x 1024 pixels, 7.0 inches
(~170 ppi pixel density)
Samsung Galaxy Tab 2 10.1 P5100 -- 800 x 1280 pixels, 10.1 inches
(~149 ppi pixel density)
As per my understanding if i correctly develop my application for above three, most of the other devices will be handled. may be?
My question is from where should i start designing my images? As the both tablets are of mdpi density but different screen sizes, i designed the images for TAB2 and placed the images in drawable-mdpi directory, those images were shown perfectly on TAB2 but on TAB7, things are messed up, images are overlapping on each other.
So, both the tablets are mdpi and for mdpi, images should be placed in drawable-mdpi but for which tablet size should i design images?
Application UI usually is not fully bitmapped. You got some elements like icons which are fixed size, but from other hand your buttons should scale without problems. So assuming you want to target all devices, you should design your UI the way it fit on smallest supported screen (in this case 600 x 1024 pixels is your max) - this means that if you preview on said screen all UI elements are fully fit on screen. On higher screens you UI have to scale, but this usually do not need any special approach (unless you work on bitmapped game for example) as elements like lists, buttons, layouts will stretch automatically. And if your design assume any bitmaps involved in said scalable elements, use 9-patch PNG files to make it scale correctly.
For more on that subject, please read "Supporting Multiple Screens".
I recommend you designing for xhdpi, you can allways resize for lower dpis.
Take into account dpi is not related to screen size, on the other side, larger screen tablets have lower dpi than most "modern" phones.
Make the layout for target screen sizes, i.e. 10" and 7" tablets, the system will take the best bitmap for your device dpis (or restcale the nearest one!).
With the latest (beta) Android SDK and Eclipse plugin you'll take a better view of the differents devices screens: dpi + pixel resolutions + screen size., they now show, for exaple, like
7" WSXVG (Tablet) (1024x600: mdpi)
in the layout editor.

Android Tablet Dimensions

We have just started Android Tablet development. I need to prototype for 7in and 10in tablets.
Is there any wireframe stencil i can get hold of ?
What are the dimensions of the canvas i need to start designing on ?
Just like phones, tablets have all sorts of dimensions and sizes.
Here is a quick list of different models with their respective sizes and dimensions:
Samsung Galaxy Tab 10.1 3G - 10.1 inches, 1280 x 800 pixels
Samsung P1000 Galaxy Tab - 7.0 inches, 600 x 1024 pixels
Dell Streak 7 - 7-inch 800×480
Motorola Xoom - 10.1-inch, 1280×800
Viewsonic G - 10.1-inchs 1024×600
These are the dimensions you'll find most often.
Rather than considering actual pixel dimensions (which can vary in size depending on pixel density), it might be easier to think in density independent pixels (dp). This is the smallest device width as given in the configuration examples from the docs:
7” tablet: 600dp
10” tablet: 720dp
Notes
For actual pixels size, multiply by 1 to get mdpi, multiple by 2 to get xhdpi, by 3 to get xxhdpi, etc. See here for more.
To provide different resources for the various screen sizes, see this answer.
Old topic but i think i've got a good way to resolve your probleme. If it can help some..
First of all, if you do right, All your activities should be composed ONLY with fragments.
You may know that when a screenSize is defined as exemple by 384* 640, that means your maxWidth is 384dp and your maxHeight is 640dp.
And so, it's easy to determine how height you should use without trying on emulator.
Still using my screenSize exemple : 384 (Widht) * 640 (Height) :
640dp
292dp
264dp '
<dimen name="max_height">640dp</dimen> <!-- screen maxHeight -->
<dimen name="half_height">292dp</dimen> <!-- ScreenMaxHeight with actionBar -->
<dimen name="half_height_bigactionbar">264dp</dimen> <!-- height without actionBar and its subActionBar -->
Down here, this is my fragment size :
<fragment
android:layout_width="match_parent"
android:layout_height="#dimen/half_height_bigactionbar"
Both of my fragmennts should now fill all the sreen
My action bar height is 56dp . If you do the map if i want he half of my screen i do ((maxScreenHeight) - (ToolBarSize) ) / 2.
I got ((640) - (56)) / 2 = 292dp !
Do the same for All of resolution you might know with all the window part you may use:
And you will have THE perfect match in every phone you know.
You can do the same math for width if you use tablet.
But remember, use as much as possible wrap_content + marginLeft and MarginRight to place your components !
When you wana create an activity. Draw it in a sheetwith small-paned . And think only with percent. Then do the math, and use ONLY fragments.
You should be fine then :). Ask if i wasn't clear enought !

Categories

Resources