I try to add a ConstraintLayout programmatically. It's working but WRAP_CONTENT
isn't working. The Layout is always MATCH_PARENT
.
The Android Developer page doesn't list WRAP_CONTENT
for ConstraintLayout.LayoutParams
My Code:
RelativeLayout rl_main = findViewById(R.id.rl_main);
ConstraintLayout cl = new ConstraintLayout(this);
cl.setId(0);
ConstraintLayout.LayoutParams clp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_WRAP);
cl.setLayoutParams(clp);
cl.setBackgroundColor(Color.parseColor("#000000"));
rl_main.addView(cl);