Root xml vs Child xml
It is important to note that child xml does not contain the layout and data tag. It can contain other child xml through the include tag. Interactive samples provided use child xml and hence layout and data tags are missing.
To develop Ashera ui, you use android studio and android widgets in Android studio. There are already lot of video tutorials on how to use android studio to create user interface. Click here to know how to use android studio to design a user interface. You can follow only how the xmls are created and ignore any topic related to java code reference as Ashera provides Generic implementation of the same.
Lets us first understand the basic structure of android xml.
The following code shows the general structure of the root xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingPrefix">
<data></data>
<!-- Root view. can be ConstraintLayout, LinearLayout etc -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e5db54"
tools:ignore="MissingPrefix">
...
<!-- Inline java script + resource -->
<View
name="@layout/cat_hello_textview"
type="javascript"
widget-override="Inline"
android:layout_width="0dp"
android:layout_height="0dp"
tools:ignore="ExtraText">
<![CDATA[
window.inlineFunction = function() {
alert("Meow meow !!!!");
}
]]>
</View>
<!-- Include other files -->
<include layout="@layout/test"/>
<!-- Include ui elements -->
<Button
android:id="@+id/loginButton"
onClick="validateMyForm"
android:layout_width="0dp"
android:textColor="#000"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.082"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent=".87" />
...
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
The following code shows the general structure of child xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- Can be ConstraintLayout, LinearLayout etc -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e5db54"
tools:ignore="MissingPrefix">
...
<!-- Include other files -->
<include layout="@layout/test"/>
...
</LinearLayout>
It is important to note that child xml does not contain the layout and data tag. It can contain other child xml through the include tag. Interactive samples provided use child xml and hence layout and data tags are missing.
Use Inline javascript to a minimum. Always create handlers in Typescript using VS Code as you get advanced refactoring capabilities. Inline javascript/resources can be used for downloadable xml cases. i.e. you download a xml using http and the file should have all the functionalities i.e. javascript, child xml. For xml downloaded via http, you bundle all the javascript and dependent resources in single xml file.
Lets us start building the classic login page. We will enhance the example as we go along in the future sections.
The steps below describe how to create an ui in Ashera: