I have created a custom view and inserted logging for an estimated performance comparison
public class CustomInAppKeyboard extends LinearLayoutCompat {
private static final String TAG = "MyKeyboard";
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if(BuildConfig.DEBUG){
Log.e("CustomInAppKeyboard", "w:" + widthMeasureSpec + " :: " + MeasureSpec.toString(widthMeasureSpec));
Log.e("CustomInAppKeyboard", "h:" + heightMeasureSpec + " :: " + MeasureSpec.toString(heightMeasureSpec));
}
}
public CustomInAppKeyboard(Context context) {
this(context, null, 0);
}
public CustomInAppKeyboard(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CustomInAppKeyboard(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
LayoutInflater.from(context).inflate(R.layout.keyboard_alphanumeric, this, true);
}
}
then using start & end times of "MyKeyboard" logs... I end up with the following values:
- ConstraintLayout withguides 14.32
- ConstraintLayout with chains 13.62
- LinearLayout (nested weights) 4.88
That was based on these xml layouts files in the following gist: - https://gist.github.com/CrandellWS/fc7946ea653cf90828580b3c00d8da57
So how can I get the ConstraintLayout to render as fast as the nested LinearLayout? What could I do differently or change to get the ConstraintLayout to more closely match the LinearLayout performance?
"actual" Keyboard layout files are known to be different
Note that there is an inability to use Systrace on my physical device https://stackoverflow.com/a/52836747/1815624 ... hence the rudimentary performance test method...