Android - Create app with pure Java and no XML?

前端 未结 6 936
清酒与你
清酒与你 2020-12-08 14:38

I\'m wondering if it is possible to create an Android app with only Java. No XML, no other things.

In Eclipse, when I create a new Android Project, the Manifest xml-

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 15:10

    For the layouts you have two options

    1. Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

    2. Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

    So for the first question - yes - you can delete xml layout files (if you must).

    I think you cannot get rid of the manifest.xml..Quoting:

    Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory.

提交回复
热议问题