I am proficient in Java and now studying the basics of Android App Development.
I want to re-use the layout activity_main.xm for a second activity to avoid the laborious work of having to re-create it in the layout editor.
In other words I want to sub-class the Activity ActivityMain but also "sub-class" its layout.
Any suggestion ?
I have searched and searched the web without success.
posted 1 week ago
Solved. The answer is in the official android tutorials:
If you already have a layout and want to create an alternative version to optimize the layout for different screen sizes or orientations, follow these steps:
1. Open your original layout file and be sure you're viewing the design editor (click the Design tab at the bottom of the window).
2. Click Orientation for Preview in the toolbar. In the dropdown list, either click a suggested variant such as Create Landscape Variant and you're done, or click Create Other and continue to the next step.
3. In the dialog that appears, you simply need to define the resource qualifiers for the directory name. You can type it in Directory name or select from the Available qualifiers list, one at a time, and click Add .
4. Once you've added all your qualifiers, click OK.
When you have multiple variations of the same layout, you can easily switch between them from the list that appears when you click Layout Variants .
It runs on an internal combustion engine. This ad does not:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps