简体   繁体   English

如何使布局支持android studio中的所有屏幕

[英]how to make layout support all screens in android studio

I'm working on app,in which there are tests for exams.The layout is easy to learn: A simple TextView for Question. 我正在开发应用程序,其中包含用于考试的测试。布局易于学习:用于问题的简单TextView。 below Question there is radioGroup with four radio buttons for alternative answers.below radiogroup there is button for next question. 在问题下方,有radioGroup带有四个单选按钮供您选择答案。在radiogroup下方有一个用于下一个问题的按钮。 When I test it on Nexus 5 with resolution 1080:1920 it works fine. 当我在分辨率为1080:1920的Nexus 5上进行测试时,它可以正常工作。 But i tried and tested it on another emulator with smaller resolution.the problem is that there are some questions with long alternative answers and the radiogroup fit the whole screen so the next button is hiden. 但是我在另一个分辨率较小的模拟器上进行了测试。问题是有些问题的答案很长,收音机组适合整个屏幕,因此隐藏了下一个按钮。 I tried small font for the radio buttons but it does not work. 我为单选按钮尝试了小字体,但是它不起作用。 What I want is any ideas how to support all screens resolutions. 我想要的是关于如何支持所有屏幕分辨率的任何想法。 I want to do it without using scrollView.Any ideas? 我想在不使用scrollView的情况下做到这一点。

You basically needs to set your app UI based on every screen class 基本上,您需要根据每个屏幕类别设置应用程序用户界面 在此处输入图片说明 click on the highlighted button/tab there u will find set screen size and just set sizes and you will be done 单击突出显示的按钮/选项卡,您将在其中找到已设置的屏幕尺寸和刚刚设置的尺寸,即可完成操作

You can add a weightsum to your principal layout and add weight for every element. 您可以在主布局中添加权重和,并为每个元素添加权重。

Ex : if you put in the main layout the weight sum at 100, you can put 40 weight for your text, 40 for your radio group and 20 for the continue button, it's like percentage. 例如:如果您在主布局中将权重总和设置为100,则可以为文本输入40权重,为广播组输入40权重,并为继续按钮输入20权重,就像百分比一样。

This will keep the size for every device 这将保留每个设备的大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM