i have a question about the app widget in android. I'm a litte bit confused, cause i define in the info xml (res -> xml) the values for width (250) and height (110) (http://developer.android.com/guide/practices/ui_guidelines/widget_design.html). Now i expected my Widget take the in the width 4 cells and in the height 2 cells.
I tested it with a Nexus S (HDPI), all works fine, i tested it with a Nexus 4 (XHDPI), all works fine, i tested it with an Samsung Galaxy Tab 10.1/Emulator tablets (MDPI), it doesn't work, Nexus7 (Emulator) (TVDPI) also it didn't work.
OK, I looked in the Menu and i see the system takes 3 and not 4 cells for the width.
Now my Question is there a way to define specific xml files for the tablets (please notice that i would support device with android 2.3.3) or am I missing something?
Have you tried putting your layout for the widgets into different folders, so that it will be rendered out differently on different screen sizes? For example, when supporting tablets you would have a layout-xlarge folder which contains the layout for your Widget on extra large screens. See here for more information about Tablet layouts.
Related
I'm trying to create layouts for various screen sizes. I have used resource qualifiers to add sw600dp and sw720dp layouts, which work well with tablets in the emulator, but I want to make some specific layouts for foldable phones, starting with an 8 fold-out, which in device manager is said to have a resolution of 2200x2480, and displaymetrics confirms that the emulator has a screen width of 2200 pixels. I made a layout using qualifiers of w2200dp-h2480dp, but this is not used when I run the emulator (the sw720dp layout is chosen instead). I thought maybe the issue is using px instead of dp, so I've also tried w835dp-h945dp (as specified for a generic 8 fold-out device in the design preview window layout options), also w787dp-h837dp (derived from the formula dp = (px/dpi)x160 applied to 2200x2480), but none of these is used when I run the emulator.
How can I create layouts for this and other specific screen sizes? Am I going about it the wrong way?
I am designing an app with a .jpeg background and with text views on particular places on the screen. I designed this for my nexus 6 and used dp for the widths and heights of text views and margin-left and margin-top. What my understanding of dp is that it changes with every device according to screen size and density. So it should work on different phones according to the value of dp for them.
But this is not the case. When I run that app on a different phone (nexus 5) the layout is all messed up. I tried using the different resources and qualifiers for different screens (large, small, normal). But the problem still prevails. The app considers both nexus 6 and nexus 5 as large screens. How do i fix this?
this is not the best solution i guess.
i guess your layout is just on the layout folder. i don't know if the first device you tested the layout is large or small but what you should do is create another folder named layout-sw600dp. this folder is used by tablets. the folder layout is used my phones and smaller devices. you could also create the layout-land and layout-sw600dp-land folders for the landscape orientation.
dp do change depending on the device but if your layout gets messed up then i guess the layout called by that device doesn't fit its resolution. i guess dp becomes smaller if the device is bigger and vice versa.
I will get straight to the point. I have my application finished and I am trying to get the layout to work on different screen sizes. My problem is with a small screen size, say 3.7" or 4". I have a layout-small,layout,layout-large, and layout-xlarge folders with different layouts for each. For Nexus 4,5, and 6, the small layout is associated with them, when I want "layout" as I used a bigger phone for those layouts.
I wanted to use the layout-small folder for Nexus One and Nexus S, as those are smaller phone and I used those emulators for the layout. For whatever reason, when I use a small phone like the Nexus One, the layout extends beyond the page while being associated with the layout-small folder, while when using the nexus 4 or 5 phone, the layout looks fine, while being associated with layout-small. It seems like Nexus One,S,4,5,6 are being shown as associated with layout-small, but are actually using layout. Any help would be greatly appreciated.
I should add that I tried doing layout-small,layout-normal,layout-large,and layout-xlarge, but everything that was associated with layout-small turned to layout-normal, and layout-small was completely dropped
Start with http://developer.android.com/guide/practices/screens_support.html You should also consider the orientation as a qualifier. The "small", "normal", "large", etc is not exact and you need to find out which it is for each device (emulator) you are testing with. Just as a test, create the folder structure with all qalifiers and have a single layout in each with a single text view that is hard coded with the resource path.
Example
res/layout-small-land/test.xml android:text="layout-small-land"
res/layout-small-port/test.xml android:text="layout-small-port"
res/layout-normal-land/test.xml android:text="layout-normal-land"
res/layout-normal-port/test.xml android:text="layout-normal-port"
I am developing a tablet-only app and I put xml files for 10 inch tablets in /res/layout-sw720dp folder.
When I preview customized xml in eclipse, I select device as "10.1in WXGA (Tablet) (1280x800: mdpi) and everything is positioned just fine (note: certain elements need to be positioned by adding some margins (in dp) ... ), but when I run this app on samsung's galaxy tab this elements are not positioned as xml editor shows.
What could be the problem?
Read link 1 and link 2 and you will get idea about how android supports multiple screen sizes.
Better use wrap content or use layout_weight attribute instead of fixing the sizes, for more consistent look on all devices
I'm developing an app that must work for multiple device screens, so, I separated the drawable and layout folders properly: large-land, large-port, sw720dp and so on.
For devices like Nexus, from Google, I'm having a problem with its menu, that is in OS, not physical, like in others devices.
So, layouts that works well in devices like SIII does not work on Nexus, it seems like shrunken, because I lost a litte of its height.
Discussing with friends, we thought in set its layout programatically, but in a screen with various elements, it's bad to keep. Is there a way to organize this layout and drawable using the android's structure, like I did for others resolutions and sizes?
Thanks in advance.
for the nexus 7 from Asus it will use the drawables in folder drawable-xhdpi so put the drawables there ... and for icons use 48x48 size so they will look the same size as an actionbar icon ...