androidscriptingnative-android

Does Android Support Runtime XML or HTML Parsing for Dynamic View Creation?


I'm working on a native Android application where screens need to be rendered dynamically based on data received at runtime. The application is database-driven, and we aim to support customization for end-users, so we cannot rely on predefined XML layouts.

I'm exploring whether there's any Android framework support for this kind of dynamic UI generation. Specifically:

Is there any XML-like scripting or markup language that Android supports at runtime to define and render views?

I'm considering sending data from C++ to Kotlin—possibly in a format like HTML or a structured markup—which Kotlin could then use to create and display widgets dynamically.

Does Android OS have any built-in capability for such markup-based dynamic view creation Essentially, I’m looking for a way to generate UI programmatically from markup or structured data passed from the native side.

To clarify what I mean, here’s an analogy from another platform:

On Windows, it's possible to define UI dynamically using runtime XAML strings, like this:

static void createxaml(hstring & str) {

 

        str = LR"(

                 <Button

                   xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

                   Name="MyButton"

                   Content="Click Me"

                   Width="200"

                   Height="60"

                   HorizontalAlignment="Center"

                   VerticalAlignment="Center"

                   FontSize="18"

                   FontFamily="Segoe UI"

                   Foreground="White"

                )";

    }

{

 

        hstring xaml;

    createxaml(xaml);

    Button obj = XamlReader::Load(xaml).as<Button>();

}

Solution

  • Does Android OS have any built-in capability for such markup-based dynamic view creation

    Other than rendering HTML in a WebView, no.

    You are welcome to explore third-party solutions, mostly in the server-defined UI (SDUI) space.