Different flavors of UI development
Ol' good XML/Java
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:padding="20dip">
<TextView android:layout_width="match_parent" android:text="ID"
android:id="@+id/userid" android:layout_height="wrap_content" />
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/userId" />
<Button android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/signin"
android:text="Sign in"/>
</LinearLayout>
example from Scaloid docs
Ol' good XML/Java
EditText userId = (EditText)findByViewId(R.id.userid);
Button signin = (Button)findByViewId(R.id.signin);
signin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
signin(userId.getText());
}
});
example from Scaloid docs
Ol' good XML/Java
- all tools support them
- documentation is using them, so no need to translating concepts into sth else
- verbose
Scaloid
new SVerticalLayout {
STextView("ID")
val userId = SEditText()
SButton("Sign in", signin(userId.text))
}.padding(20 dip)
example from Scaloid docs
Scaloid
- less verbosity
- uses Scala features to create DSL
- has online converted from XML to Scaloid (for supported features)
- wraps everything in new classes/traits - it is hard to mix Scaloid with Java code
- some methods run on an UI thread
- no support for some newer SDK features (e.g.
android.support.v4.widget.DrawerLayout
)
- last update 2 months ago
Macroid
var userId = slot[EditText]
l[VerticalLinearLayout](
w[TextView] <~ text("ID"),
w[EditText] <~ wire(userId),
w[Button] <~ text("Sign in") <~ On.click(signin(userId.get.getText))
) ~> padding(all = 20 dp)
example from Macroid docs
Macroid
- maintained by 47deg
- as little verbosity as with Scaloid
- works with all Android components
- really nice support for async - UI actions as IO monad (unfortunately they don't work with for-comprehension)
- thread safety (as opposed to vanilla Android SDK)
- last update 3 months ago
Macroid
val action: Ui[Button] =
(startButton <~ disable) ~
(stopButton <~ enable)
import macroid.FullDsl._
runUi(action)
Protify
demo from Protify's page