Profile cover photo
Profile photo
Eduard Bolos
88 followers
88 followers
About
Eduard's interests
View all
Eduard's posts

Post has shared content
We have been playing with +Firebase for a bit at +Novoda and we wrote and app and a blog post to share our thoughts. novoda.com/blog/bonfire/

Post has attachment

Post has attachment

Hello! Am I the only one who got a British charger with their Meizu MX4 Ubuntu edition? I was expecting for a European (CEE) one...

Post has shared content
Pro-tip: layout_ attributes are instructions to the parent ViewGroup and found in its LayoutParams
When writing your layout XML files, you'll use a lot of different attributes to get things looking great. Looking up the documentation behind the attributes can give you a lot of insight into what exactly each does - but where do you find that documentation?

Take a look at a simple example:
<android.support.design.widget.AppBarLayout>
  <android.support.v7.widget.Toolbar
    app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget. AppBarLayout >

Your first thought in figuring out what app:layout_scrollFlags does might be to look at Toolbar's documentation, but you'll find that Toolbars don't actually know anything about scrolling. The prefix layout_ denotes attributes that are instructions to the parent ViewGroup - in this case, an AppBarLayout. But looking at the documentation of AppBarLayout still doesn't show that attribute. Hmm.

Turns out: those attributes are stored in what are called LayoutParams - a helpful class associated with each View where the parent ViewGroup can store, you guessed it, parameters that affect how the ViewGroup will lay out that child View (such as how that view should react to scroll events). Every View has a getLayoutParams() [1] method which must return a non-null value once a View is attached to a parent.

This also explains why it is so important to pass in a non-null parent to LayoutInflater.inflate() [2] - only then will the appropriate LayoutParams be created (passing null means all layout_ attributes will be effectively ignored!).

In this case, AppBarLayout.LayoutParams [3] is a custom subclass of LayoutParams that contains all of the information about the layout_ attributes (and their programmatic alternatives) that are specific to AppBarLayout - including the layout_scrollFlags!

This means that retrieving the LayoutParams involves casting the result of getLayoutParams() to the correct subtype based on the parent of the View:
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
// Now you can call params.getScrollFlags() or params.setScrollFlags()

This also helps explain the difference between android:gravity (instructions to the View on where to position its contents) and android:layout_gravity (instructions to the parent ViewGroup on where to put the View).

[1] - http://developer.android.com/reference/android/view/View.html#getLayoutParams()
[2] - http://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int,%20android.view.ViewGroup,%20boolean)
[3] - http://developer.android.com/reference/android/support/design/widget/AppBarLayout.LayoutParams.html

Post has shared content

Post has attachment
Hi! I've created this watchface for my Moto 360, and now I am sharing it with you. Enjoy! #moto360 #watchface

Post has attachment
Hi! I created this watchface for my Moto360, and I am sharing it with you. Enjoy!

Post has attachment
Here it's my watchface, called Circles Watchface.
#watchface  
Photo

Post has attachment
Wait while more posts are being loaded