0

I'm trying to add two divider via XML into the app. I have aligned the divider with some buttons.

I want to avoid to aglign the divider with the parent and then add margins to each side of the divider.

Is there a possibility to keep the divider aligned to the buttons and make the dividers slighlty longer (marked red) on both ends for each divider (vertical as well as horizontal)

is that possible?

https://i.stack.imgur.com/DNYrz.jpg

I've tried to add negative margins but that did not work (sounds probably super stupid).

<View
    android:id="@+id/view"
    android:layout_width="1dp"
    android:layout_height="0dp"
    android:layout_marginTop="8dp"
    android:background="#000000"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="@+id/button_onePointTeamb"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/textView_teamb" />

<View
    android:id="@+id/view2"
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="8dp"
    android:background="#000000"
    android:visibility="visible"
    app:layout_constraintBottom_toTopOf="@+id/textView_scoreTeama"
    app:layout_constraintEnd_toEndOf="@+id/button_threePointsTeamb"
    app:layout_constraintStart_toStartOf="@+id/button_threePointsTeama"
    app:layout_constraintTop_toBottomOf="@+id/textView_teama" />

Is it possible to do that?

Hooni
  • 354
  • 1
  • 4
  • 13
  • Add an invisible View (visibility:invisible ? ) to the right of a button and below the bottom most button. Align your divider with these views. – Neeraj Feb 07 '19 at 13:50
  • 1. Make two containers inside parent. One for dividers and other one for containing the items. Now, give this second container a margin and you have got your issue resolved. Also, as you are using constraintlayout, you can use guidance. – Rahul Feb 07 '19 at 13:54
  • Instead of negative margins you could try the suggestion of the accepted answer for this question : https://stackoverflow.com/questions/45670999/android-constraintlayout-does-not-allow-negative-margins which is to use Space views in your layout – Xavier Falempin Feb 07 '19 at 15:42

0 Answers0