120 questions
-1 votes
1 answer
74 views
Android: Very difficult to achieve the same layout proportions / aspect ratio between phones and tablets
When I say "the same layout proportions" I'm mainly referring to text sizes, but also to views in general. I've always read that sp text size units are screen independent, but that's not ...
1 vote
1 answer
2k views
Do I need to parse Int to dp before using the .dp extension function in compose?
Suppose I have a screen in figma with 1080x1920 resolution, then I add 20px padding, when I recreate this layout with compose I need to parse 20 to dp (using some utility function like: val Int.dp: ...
2 votes
0 answers
271 views
How does Jetpack Compose handle drawable resources for different screen densities?
I'm a total newbie with Jetpack Compose. I hope you may help shed some light on my issue. In the old days, if you had a PNG drawable resource, you would provide multiple versions of that drawable ...
2 votes
2 answers
2k views
Why displayMetrics.density is wrong?
On my Pixel 7 device, I want to know how many density-independent pixels (dp) I have. So, I use this formula: displayMetrics.widthPixels / displayMetrics.density However, I have an issue because ...
0 votes
0 answers
43 views
how to change th value of layout in MainActivity.java?
i am using android studio in x.xml, i set the layout_height=400dp <RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="wrap_content" android:...
0 votes
1 answer
85 views
How can I know the pixels range for all screen densities in Android ? (base density of an image)
So imagine that I have an image that is 700x700 px in res folder and I want my app to support different pixel densities. So according to the documentation: ldpi -- 0.75x mdpi -- 1x hdpi -- 1.5x xhdpi -...
0 votes
1 answer
79 views
Formula to convert any dpi to any dpi
I need the formulas to calculate any dpi to any dpi. For example: mdpi to hdpi, xdpi to xxhdpi, etc. This website exactly does what I require but I am not able to find the logic for it. Any ...
0 votes
0 answers
94 views
calculus of dp and actual dp doesn't match
i calculated the dp of a device (smallest width), in particular a google pixel 3 (440dpi 1080x2160), using the formula: px = dp*(dpi/160) the result was 392.72, so i created the file animator-sw390dp-...
0 votes
0 answers
134 views
How can I determine the dimens of each screen? - Android studio
I am new to programming and I didn't quite understand the dimens, I know there are small, normal, large and xlarge screen sizes. I also know the densities: ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi. I ...
14 votes
2 answers
7k views
Android Compose set height of view in pixels NOT in dp
I want to set the height of view in pixels not in dp. `Box(modifier = Modifier.height(100.dp))` In this example height of the box is set to 100 dp and modifier function accepts only dp. How to set ...
1 vote
1 answer
806 views
React-Native: Text is rendering differently in different mobile phones
This is the style I ma using to render Text TEXT_B16: { fontFamily: 'OpenSans-Bold', fontWeight: fontWeight, fontSize: 16, lineHeight: 22, }, And output is as follows, Samsung One ...
0 votes
0 answers
127 views
Text is stretched on different screen in my custom view after settings text size in dp android
I am trying to create a text sticker in android. I am creating a text sticker on one of my phones and then saving the text size in the DP. Then on another phone, I am loading the same text with the ...
1 vote
0 answers
251 views
is galaxy s10 (xxxhdpi) scaled 4x or 3.5x?
https://material.io/resources/devices/ (which is not maintained anymore) has 3.5x for xxxhdpi google pixel xl 4x for xxxhdpi galaxy s8 https://material.io/blog/device-metrics lists only 4x for ...
1 vote
0 answers
55 views
Negative margin on different devices
Source code can be found at : https://github.com/AliRezaeiii/Contacts I have following layout in my Activity : <?xml version="1.0" encoding="utf-8"?> <androidx....
1 vote
0 answers
32 views
Difference in items height at layouts with same DP value
I am running 2 emulators: 360x640 mdpi (1x) 1080x1920 xxhdpi (3x) Using dp values when defining attributes for views should result in covering same physical space, but as the result they look ...