1

I am adding my views to constraint layout programmatically. The view has an image and title which should come at the bottom of the image with some margin. When I am applying margin to the textview, margin applies to image as well.

Below is my code

set.connect(showimage.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, 0);
    set.connect(showtitle.getId(), ConstraintSet.START, showimage.getId(), ConstraintSet.START, 100);
    set.connect(showtitle.getId(), ConstraintSet.BOTTOM, showimage.getId(), ConstraintSet.BOTTOM, 0);

And this is the output i am getting can someone help me out

enter image description here

WISHY
  • 11,067
  • 25
  • 105
  • 197
  • 1
    Post your XML too. – Enzokie Sep 12 '19 at 04:30
  • @Enzokie there is no XML i am doing this via java code – WISHY Sep 12 '19 at 04:37
  • Not enough info for me to conclude! For workaround try replacing your second constraint with this `set.connect(showtitle.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, 100);`. – Enzokie Sep 12 '19 at 04:46
  • mention what do you want and what's issue – Hanzala Sep 12 '19 at 05:24
  • You can try scaling the image with image = Bitmap.createScaledBitmap(image, 1500, 1500, true); and then set the constraint via percentiles instead of pd...so basicly set the constraints via percentiles so 10% from the right etc. then scale the image to fit into the constraints also add left and right constrints – Ruben Meiring Sep 12 '19 at 06:27

0 Answers0