Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Creating a base layout that can be re-used and extended for other activities

 
Ranch Hand
Posts: 75
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Afternoon,

I am proficient in Java and now I am studying basics of Android Development in Android Studio.

I want to re-use the layout activity_main.xml in another activity to save the laborious work of re-creating it in the layout editor.
In other words I want to sub-class MainActivity but also "sub-class" its layout.

Any suggestion ?

I have searched, and searched the web for an answer without success.

Thanks
Mohammed.
 
Mohammed Azeem
Ranch Hand
Posts: 75
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved. Answer in 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  .



 
Mohammed Azeem
Ranch Hand
Posts: 75
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I'm sorry it is not solved

The info I found does not answer my query.

Any suggestions most welcome.

Mohammed.
 
Fire me boy! Cool, soothing, shameless self promotion:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!