I have a quick question. My team, 2729, is currently finishing our scouting application project. We have created two apps (one called the master app and one called the user app). We have created scouting apps for the past four years and received tons of help, and we are looking for more!
Our problem is that our apps are only compatible for our test devices, Nexus 7 (mini tablet). As we are finishing up our app, we wanted to make it Universal for all android devices to expand our platform market.
We have tried using multiple constraints (linear layout, constraint layout, match parents, wrap contents, and scroll views) but none have helped us. We are in dire need of assistance as the many times we experimented with unaware layouts, we have had to restart (four times and counting).
My team utilizes a similar scouting system, though we only have a user app and a desktop client to compile/analyze the data. We found that using relative layouts is useful in making the app compatible across most devices (both phones and tablets), though minor tweaks to margins/padding might be necessary to make text display properly on all devices. In one activity, we had to adapt different layouts for phones and tablets.
As the app developer for my team, here’s my take on what is the best for compatibility.
Use a RelativeLayout as the base layout of the layout file, it will be at the top of tree.
Then, the only direct child of that RelativeLayout should be a ScrollView.
Inside of the ScrollView, have a RelativeLayout, this is where the bulk of your app will go.
Buttons that are only one in a row or column should just be match_parent for the height or width (depending on whether your app is left to right or up and down).
If you need 2 buttons side by side, use a horizontal LinearLayout with the scrolling direction dimension being wrap_content. Then inside of that, use the other type of LinearLayout with the scrolling direction being wrap_content in the second set of LinearLayouts, the layout weight property being 1. Then put the buttons in the second set of LinearLayouts.
If you need something that I haven’t mentioned, just say so and I will try to help you. Admittedly, this is all I have ever needed, so it should hopefully be sufficient.
Why not have the ScrollView as the root? That extra RelativeLayout at the root isn’t doing much for you. If you need a different container at the root for some reason, FrameLayout would at least be slightly more efficient since it has a much less complicated layout process.
@Prans792 some screenshots would help identify the source of your problems, along with posting a link to your layout file on GitHub or in a gist.
The app I am basing this off of was developed by a former team member last year, and I am repurposing it this year. He used what I described, but I don’t know if they way he loads the different screens for auto and teleop requires having a RelativeLayout as the root, and not a ScrollView, but if you are doing it a simpler way, ScrollView would be better I think. Admittedly, until this, I didn’t know that ScrollView didn’t have to be nested in something. I just thought, “oh, it says view so it needs a parent” up until this point. You learn something new everyday!