Kivy TreeView: collapse button really small on android - android

I'm using TreeView to build an app, and it renders fine when testing on my laptop but the little buttons to collapse/uncollapse tree nodes are tiny on my phone (see the tiny arrow next to Group 1 in the image). I've looked for an attribute or property in TreeView that I could set, but nothing seems to help.

It's probably because using an invalid sizing units. I guess you either used width = 100 or width = 100px or similar thing. Mostly phones and tablets, but even other displays handle such things a little bit differently.
To fix that use dp unit described in the link provided above:
.py:
width = '100dp'
.kv:
#:import dp kivy.metrics.dp
width: dp(100)
To test how the layout looks at such devices use screen module or the commands mentioned in kivy.metrics documentation to manually modify DPI of your application. Screen is more powerful.

Related

How to know all the dimens.xml(hYYYdp) files I have to create to support all the screen sizes?

I am a little bit desperate because I'm trying to know how can I know the exact list of different dimens.xml(hYYYdp) I have to create in order to support all the screen sizes. I think I have already seen all the related questions to mine but none of them has helped me to solve this doubt. This is the most related question that hasn't solved my doubt: How to define dimens.xml for every different screen size in android? .
To give you some context. The reason of having different values according to the screen size is because I have a ConstraintLayout with some items that have Top and Bottom margin and in some devices that margin is not looking good. In this post I made, someone suggested me to use different margin values according to the screen size: How to solve TextView being cropped in small devices because of layout margin?
I have thought that as the margin is dependent of the height of the device (as I am using only Top and Bottom margin) I would have to create a list of different dimens.xml files according to the height of the device (hYYYdp).
The real concern I have is that I don't know how many dimens.xml files I have to create to support all the screen sizes. What I have been doing is creating some specific dimens.xml files that are working for specific devices, but I think there has to be a general list of all the dimens.xml files that have to be created to support all the screen sizes.
For example, what I have been doing is to look the test devices of Android Studio one by one and create specific dimens.xml files for them. This is the process I have followed to create a specific dimens file:
Example:
1- First I have seen the list of the test devices of Android Studio, for example let's take this one:
2- After this, I have calculated the dp of the height of this specific test device:
240x400px (ldpi) device. So the height's dp is = 400/(120(ldpi)/160)== 533.33dp
3- Finally, I have added the dimens.xml(hYYYdp) correspondent to this specific device with the specific margin value that is looking good:
I have repeated this process for most of the test devices of Android Studio but as a result, I have a list of specific devices but I think there will remain many devices without being supported as not all the Android devices are in the Android Studio test devices list. I hope you have understand what I am trying to explain.

layouts designed in sketch software doesnt match when implemented in android

I have set a linear layout as 32 dp in sketch app using mac and when the same dimesnsions implemented in android studio and then i took the screen shot and imported to sketch app and when compared with the sketch designed measurements there was a huge difference in the height i.e the height was 44dp so can some help me out in this how to match exact measurements from sketch to android layouts.
I have faced this problem many times and found this solution which worked for me
In sketch first use the art-board which fits material design
for eg: 360 x 640
Get you design fit in height can vary and than try to export your design using zeplin, creat your android project using zeplin and export all your screens, zeplin will help you telling exact font, font size, images size also it allows to copy xml to be used in android studio and this give almost perfect result only difference while comparing is android bottom buttons and screens you need to adjust manually

Can an Android layout scale to fill the screen?

So I have an Android forms-based app that fills a 7" screen beautifully, portrait only, and there are over 50 forms. Rather than have to redesign each form (or the entire app) to suit each different resolution, my business case solution is to just scale the form to fill the screen. A 10" tablet will look a bit spaced out (but I can add some margins), and on a phone you better have a stylus and good eyesight!
Rather than argue about whether these are good choices, my question is: can it be done? On Windows CE the forms scale with the text size via "dialog box units", which works quite well. Android doesn't have anything like that, unless there are tricky ways of using 'sp' units. Regardless, getting a form to fill a screen nicely on different resolutions looks like hair-pulling-out territory, unless I'm missing something.
In answer to comments, it's a native app defined using XML layouts. For an example, you could take just about any sample app and show how to make it scale to different screen sizes, so you if the screen is small you get tiny text regardless of resolution.
Just to be clear: I don't think this question can be helpfully answered by describing how to use the standard Android way of handling multiple screen sizes: http://developer.android.com/guide/practices/screens_support.html. This is what I don't want to do this time. This really is about how to do other thing -- scaling to fit -- for when you really need it.
I hope I understand your situation well:
If it is a web application (you are using a webview) then use the viewport tag:
<meta name="viewport" content="width=device-width;">
This will fit the page content to the device screen.
Or if it is a native application (also would work for a web application), you can add fill-parent for your layout heigth and width, in your layout XML.
Use this code:
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = display.getHeight();
To get the height and width of any Android screen, and with this particular dimension, set the proportion for your layouts.
For example,
RelativeLayout fieldMain = (RelativeLayout)findViewById(R.id.field_layout);
fieldMain.setLayoutParams(new RelativeLayout.LayoutParams((Int)(0.8*width), (int) (0.9*height)));

screen.width and screen.height different values in different APIs/devices

Edit: also happens with $('body').width() and window.outerWidth
API 2.3.3 HVGA
Before and after rotating device outputs same screen width (320)
API 3.0 WXGA
Width and height toggle each rotation for example
starts with screenWidth:1280 screenheight: 800
I rotate 90
now has screenWidth:800 screenheight: 1280
so what do I do if I want to make certain changes on rotations
according to dimensions and want to target all APIs? I need a value which is the same for all devices.
Edit: For certain things I need pixel values, not percentages. That's why I'm using Javascript to calculate size based on screen width. This would work, since screen width is also pixel values and I can keep things proportional. But if sometimes screen.width gives me the current width, and others not, I can't use it...
-> The thing is I started working with a slider which uses absolute layout and needs pixel values for everything. I don't want to reimplement the slider, so I decided to calculate dynamically the size of the images and the whole layout using screen width. And initialize the slider with these values.
update
Look here is a similar approach to what I'm trying to do:
http://ryangillespie.com/phonegap.php#/phonegap.php?
Entry of June 18, 2011
"One Screen Resolution to Rule Them All"
I tried also with exactly that example, copy pasting it in my code. But it doesn't work either. window.outerWidth has the same problems as I'm describing for screen.width (as well as JQuery $('body').width()). It works as long as the device isn't rotated - it initializes well. But at the first rotation, depending of the device, I get problems. In some it works as expected, in others it interchanges the values, so that I get large width in portrait mode and short in landscape, in others it gives fixed width and height all time, in others it doesn't rotate at all....
Responsive web design techniques. I give a super brief example on my blog along with a book recommendation.
http://simonmacdonald.blogspot.com/2012/01/on-eight-day-of-phonegapping-multiple.html
I use media queries in two of my PhoneGap Apps. No javascript, except in
the case of anomalies.
For example, the "base" css could be for width 320 and portrait,
then using the cascading effect of css :-) add blocks like:
#media screen and (max-width: 480px) and (orientation:portrait) { make stuff bigger}
#media all and (min-width: 800px) { make stuff even bigger }
With queries like these in my link'd css files (and the device/os/phonegap
handling of orientation changes) the new layouts happen auto-magically.
NOTE: I learned all this from reading Simon's blog and the materials he suggested.
Coincidentally I found that this works:
$(window).resize(function() {
updateScaling($('body').width());
});
This is always called and passes correct width. As far as I remember it also works with screen.width
In updateScaling I calculate a scalingFactor and adjust my elements.
I tried out responsive CSS, media queries and so on, but at some point it didn't make sense anymore, because I have anyways to recalculate the margin of slider's UL based on current slide and new width - and other stuff which needs script. So I made everything with script.
I removed window.onorientationchange.
I'm not aware how phonegap presents in information for you, but for a native Android application you typically declare different layouts and image resources for various display densities and screen sizes/widths. See this page for more information: http://developer.android.com/guide/practices/screens_support.html

Android - QVGA screen hides some pixels

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.

Categories

Resources