how to work with auto layout classes in one phone only
for example I want to make distance between screen top edge and the element 50 px in iphone 4 but in iPhone 5 i want to make it 100 px
i need to but distance for each device separately
Related
I've been making a website with react and I've been using css with classNames. I also was following a figma document where the figma screens were a certain size lets say x pixels by y pixels. But, on other computers, it might have a larger or smaller pixel dimension (a pixels by b pixels). I've used the x by y pixel for div dimensions as well as button sizes and more. So, when I open my application on other computers with a larger pixel dimension, a portion of the screen is just white, and it still displays the website as if it were on a smaller screen. Is there a way to fix this so that even though I used pixel values my app will adjust to different sized screens? Or, do I have to go back and change everything to percentages?
You need to think about proportion when building your UI.
1- Use percentage(%) for width and aspectRatio for height, or vice versa.
container: {
width: "100%",
aspectRatio: 10 / 3, //height will be "30%" of your width
}
2- Use flex for the jobs percentage can't do. For example, if you have arbitrary size of items in a list and you want them to share equal sizes. Assign each of them with flex: 1
3- Use rem from EStyleSheet instead of pixels. rem is a scale factor. For example, if your rem is 2 and your “11rem” will become “11*2” = “22”. If we make rem proportion to the screen sizes, your UI will scale with any screen sizes.
//we define rem equals to the entireScreenWidth / 380
const entireScreenWidth = Dimensions.get('window').width;
EStyleSheet.build({$rem: entireScreenWidth / 380});
enter code here
//how to use rem
container: {
width: "100%",
aspectRatio: 10 / 3, //height will be "30%"
padding: "8rem", //it'll scale depend on the screen sizes.
}
4- Use scrollView for contents that could potentially scale out of the boxes. For example, a TextView
5- Every time you think about using pixels, consider use rem in method 3.
The requirements are:
Buttons that number from 0 to 9
Buttons should be evenly spaced from each other, and fit any screen size
See the screenshots to get how can it be done.
I've kept width constraint and height constraint constants of NumberPad View to 300 and 400 respectively. You can change these constants and the number buttons will automatically adjust accordingly. Let me know if you want more clarity.
Views:
Animated Views:
Constraints:
This solution might not be so great if your buttons have a background color, mine was clear.
I laid out the 10 buttons in a 4 x 4 grid, with button 0 taking up the entire row on the bottom.
I started by pinning the 0 button to the left, bottom, and right of the container.
I then pinned the top left corner button, the 1 button, to the top and left of the container.
For the 2 button, I pinned to the left of the one button, and the top of the container.
For the top right corner button, the 3 button, I pinned to the left of the 2 button, the top and right of the container.
I made the 2 and 3 button have equal widths and heights of the 1 button.
I repeated this for the remaining buttons, but made sure to make the heights and widths equal to those of the 1 button.
When I finished at the 9 button, I pinned the 0 button to the vertical space above with a constant of zero.
I updated the frames, and was happy with the result.
I made sure to make sure all the pinning had a zero constant.
I searched high and low for a solution on Google and Stackoverflow, and couldn't find anything ideal for me, so I decided to do it on my own, and just contribute an answer for record keeping, while helping anyone else out in the process.
Let me know if you have any questions.
http://www.bootply.com/ySKc5Jc7B4
The initial arrangement is:
1 2 3
4 5 6
If I now gradually decrease the window's size then the grid suddenly jumps to:
1
2
...
6
I would like to have an intermediate step with two columns:
1 2
3 4
5 6
I assume this behaviour is called fluid(ity) - hence I tried the container-fluid class for the container div. But that didn't do it and furthermore messed with the initial grid sizing.
Is it possible to make a grid behave in such a sensible way?
(I'm pretty new to Twitter Bootstrap (3))
Sure. You just need to change the class names on your tiles.
Go from col-md-4 to a combination like col-lg-4 col-md-6 col-xs-12. What that's telling it to do is:
For large screens, take up 4 of 12 columns.
For medium screens, take up 6 of 12 columns.
For very small screens, take up 12 of 12 columns.
Hope that helps.
Example here
I have a Bootstrap carousel (slider) that shows 3 images and advances 1 each time.
It stacks vertically when it's in mobile view mode (screen width < 768); I want it to collapse into showing only one slide at a time and to keep advancing one slide at a time.
I'm afraid you'll have to do that manually , there's no option that allows you to accomplish this functionality
We have 2 devices with different screen resolutions (800 x 600 and 800 x 480). Our client, who has a website fixed to 800 x 600, wanted to display their website on both devices. I checked QWebView's/QWebFrame methods and there's only one zoomFactor. Is there a way I can have different zoom factor for vertical and horizontal components? Thanks!