Activity Layout: Fragment class: vs android:name attributes

As Activity.onCreateView source says: String fname = attrs.getAttributeValue(null, “class”); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Fragment); if (fname == null) { fname = a.getString(com.android.internal.R.styleable.Fragment_name); } That seemingly means that program looks “class” attribute first. And on fail looks “name” attribute. So as far as it’s true using “class” if more efficient.

Toolbar in AppBarLayout is scrollable although RecyclerView has not enough content to scroll

Edit 2: Turns out the only way to ensure Toolbar is not scrollable when RecyclerView is not scrollable is to set setScrollFlags programmatically which requires to check if RecyclerView’s is scrollable. This check has to be done every time adapter is modified. Interface to communicate with the Activity: public interface LayoutController { void enableScroll(); void … Read more

Vertical content align in Android EditText

Try this: android:gravity=”top” <EditText android:layout_gravity=”center” android:id=”@+id/txtMessage” android:layout_height=”wrap_content” android:layout_below=”@+id/lblMessage” android:layout_width=”wrap_content” android:width=”250dip” android:text=”hello” android:maxLength=”760″ android:gravity=”top” android:lines=”4″/> so android:gravity=”top” sets the text at the “Top” Position. You can also set different android:gravity attribute value such as center, bottom, center_vertical, left, right, center_horizontal, etc. Enjoy !!

android – apply selectableItemBackground in xml with support v7

Since the attribute is defined in a library (support v7), you would use it as a user-defined attribute: i.e without the android: prefix: android:background=”?attr/selectableItemBackground” The error you see is pointing out that ?android:attr/selectableItemBackground is available for API versions >= 11. True, indeed.

Different resolution support android

App launcher icon size in pixels for different resolution Mobile Resolution mipmap-mdpi (48X48) mipmap-hdpi (72X72) mipmap-xhdpi (96X96) mipmap-xxhdpi (144X144) mipmap-xxxhdpi (192X192) Tablet Layouts: Use following folders if you wish to have tablet-specific layouts: layout-large-mdpi (1024×600) layout-large-tvdpi (800×1280) layout-large-xhdpi (1200×1920) layout-xlarge-mdpi (1280×800) layout-xlarge-xhdpi (2560×1600) Drawables folders: Mobile res/drawable (default) res/drawable-ldpi/ (240×320 and nearer resolution) res/drawable-mdpi/ (320×480 … Read more