ConstraintLayout

Nice extra thing I learnt. You can set dummy text to textviews for designview that don’t appear in the app. You replace android:text with tools:text.

<TextView
  android:text="Dummy Text Here"
  tools:text="Dummy Text Here"
  .../>

And then that data is never displayed in the app. Great!

Other than that, this segment just the awesome easy awesomeness of ConstraintLayout. But honestly, it’s so self-explanatory that it is barely worth explaining, other than to say that it’s better than Relative/LinearLayout in just about every way.

Hierarchy Viewer

I never knew about this. The Hierarchy Viewer allows you to see the View Hierarchy of your app, through the ADB. That means that if you open a view, and click on text, you can instantly see exactly what Code in your app that view correlates to.

That sounds stupid, but I’ve wasted hours opening other people’s code, seeing a “Profile” screen, then searching for the “Profile Activity/Fragment” and then the “Account Activity/Fragment” then the “User Activity/Fragment” until I finally know for certain which view is which.

Naming is hard, and this tool helps.

Data Binding

Wow. This seems quite powerful. If you have a view that is obviously just the display of a data-object, you can set everything in the XML file, and just pass the view the relevant object and it will update automatically. If changes are required beyond just displaying the object content strings, you can do that easily as well.

You can even pass it a Handler type object with void methods, to be used in the OnClick XML field, and the View can pass the bound data-object to that method. Like so:

  <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:onCheckedChanged="@{(cb, isChecked) -> presenter.completeChanged(task, isChecked)}" />

There is the automatically generated LayoutBinding, as well as the ListItemBinding for use in RecyclerViews.

Though strangely, the Udacity course doesn’t go into any of these details, and simply show you how to assign each item to each view through the auto-generated LayoutBinding.

 

Material Design

The course explains a bit about Material Design Guidelines, and shows you how to implement nicer designs. There is a very nice Material Design Color Generator they link to as well.

There’s also a nice section on typography, and some of the font families available by default to Android Developers, as well as the guidelines you need to follow for buttons/textviews/headers/etc.

 


Leave a Reply

Your email address will not be published. Required fields are marked *