How to use isInEditMode() to see layout with custom View in the editor

isInEditMode()should be used inside the Custom View constructor. Try the following code: public class GraphView extends View implements Grapher { public GraphView(Context context, AttributeSet attrs) { super(context, attrs); if(!isInEditMode()) init(context); } public GraphView(Context context) { super(context); if(!isInEditMode()){ touchHandler = new TouchHandler(this); init(context); } }

Android custom view group delegate addView

Views inflated from a layout – like your example TextView – are not added to their parent ViewGroup with addView(View child), which is why overriding just that method didn’t work for you. You want to override addView(View child, int index, ViewGroup.LayoutParams params), which all of the other addView() overloads end up calling. In that method, … Read more

Dynamic height viewpager

Made a few tweaks in your code and it is working fine now. 1] onMeasure function wasn’t proper. Use below logic @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mCurrentView == null) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; } int height = 0; mCurrentView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = mCurrentView.getMeasuredHeight(); if (h > height) height = … Read more

MonoDroid: Error when calling constructor of custom view – TwoDScrollView

Congratulations! You’ve hit a leaky abstraction. :-/ The problem is this: for better or worse, virtual method calls from constructors invoke the most derived method implementation. C# is the same as Java in this respect; consider the following program: using System; class Base { public Base () { Console.WriteLine (“Base..ctor”); M (); } public virtual … Read more

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