Set layout_column and layout_row in GridLayout programmatically

The equivalent of layout_column and layout_row, as with all layout_… parameters, is to be found as a parameter of a subclass of LayoutParams. In this case it’s GridLayout.LayoutParams, and we use it like this (for a 2×2 grid with a subview in the final row and column, centred within the cell): gridLayout.setColumnCount(2); gridLayout.setRowCount(2); gridLayout.addView(subview, new … Read more

Android getMeasuredHeight returns wrong values !

You’re calling measure incorrectly. measure takes MeasureSpec values which are specially packed by MeasureSpec.makeMeasureSpec. measure ignores LayoutParams. The parent doing the measuring is expected to create a MeasureSpec based on its own measurement and layout strategy and the child’s LayoutParams. If you want to measure the way that WRAP_CONTENT usually works in most layouts, call … Read more

How can you get the Manifest Version number from the App’s (Layout) XML variables?

There is not a way to directly get the version out, but there are two work-arounds that could be done. The version could be stored in a resource string, and placed into the manifest by: <manifest xmlns:android=”http://schemas.android.com/apk/res/android” package=”com.somepackage” android:versionName=”@string/version” android:versionCode=”20″> One could create a custom view, and place it into the XML. The view would … Read more

Custom designing EditText

Use the below code in your rounded_edittext.xml <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <solid android:color=”#FFFFFF” /> <stroke android:width=”1dp” android:color=”#2f6699″ /> <corners android:radius=”10dp” /> </shape> This should work