android - Why will previously used constraint layouts not display correctly? - Stack Overflow

admin2025-04-19  0

Last week I put my app on github. In the process Android Studio suggested some changes to address warnings some of which I made. I also added a couple of features. This week I noticed that some of the layouts don't display correctly even though I didn't modify them. I even copied the source from a previous version of one layout and it still doesn't display correctly either in Android preview or the app. It seems the list views don't expand to the constraints.

Here's the before and after

The xml source is pretty long so I'm only showing the source for the list views.

    <ListView
        android:id="@+id/CardBoxes"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="12dp"
        android:fastScrollAlwaysVisible="true"
        android:fastScrollEnabled="true"
        android:paddingRight="8dp"
        android:scrollbarStyle="outsideOverlay"
        app:layout_constraintBottom_toTopOf="@id/mergeIntoBox"
        app:layout_constraintEnd_toStartOf="@id/CardSchedule"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/positioner" >

    </ListView>

    <ListView
        android:id="@+id/CardSchedule"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="12dp"
        android:fastScrollAlwaysVisible="true"
        android:fastScrollEnabled="true"
        android:paddingRight="8dp"
        android:scrollbarStyle="outsideOverlay"
        app:layout_constraintBottom_toTopOf="@id/mergeIntoBox"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/CardBoxes"
        app:layout_constraintTop_toBottomOf="@+id/positioner" />



Question one is what configuration setting would prevent constraint view from working?

Question two is if I have to go back to a previous version how do I fix the github repository to match?

Last week I put my app on github. In the process Android Studio suggested some changes to address warnings some of which I made. I also added a couple of features. This week I noticed that some of the layouts don't display correctly even though I didn't modify them. I even copied the source from a previous version of one layout and it still doesn't display correctly either in Android preview or the app. It seems the list views don't expand to the constraints.

Here's the before and after

The xml source is pretty long so I'm only showing the source for the list views.

    <ListView
        android:id="@+id/CardBoxes"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="12dp"
        android:fastScrollAlwaysVisible="true"
        android:fastScrollEnabled="true"
        android:paddingRight="8dp"
        android:scrollbarStyle="outsideOverlay"
        app:layout_constraintBottom_toTopOf="@id/mergeIntoBox"
        app:layout_constraintEnd_toStartOf="@id/CardSchedule"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/positioner" >

    </ListView>

    <ListView
        android:id="@+id/CardSchedule"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="12dp"
        android:fastScrollAlwaysVisible="true"
        android:fastScrollEnabled="true"
        android:paddingRight="8dp"
        android:scrollbarStyle="outsideOverlay"
        app:layout_constraintBottom_toTopOf="@id/mergeIntoBox"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/CardBoxes"
        app:layout_constraintTop_toBottomOf="@+id/positioner" />



Question one is what configuration setting would prevent constraint view from working?

Question two is if I have to go back to a previous version how do I fix the github repository to match?

Share edited Mar 4 at 3:33 Dana Bell asked Mar 3 at 21:58 Dana BellDana Bell 776 bronze badges 4
  • The title suggests that pushing your local commits to a remote repository would somehow modify your local code so that it doesn't work anymore. That's not possible and that's not how Git works. Whatever Git issues you have, you should ask them as a separate question since they are entirely unrelated to the rest of your question. – tyg Commented Mar 3 at 22:04
  • I understand git would not modify the code. As I mentioned Android Studio displayed some warnings and errors and I tried fixing them and apparently changed something to break constraint layout functionality. – Dana Bell Commented Mar 4 at 3:07
  • Oh. Sorry. The title was misleading. I modified it. – Dana Bell Commented Mar 4 at 3:34
  • 1 If your project is on git, and you have the old and new code- I'd diff the two, and figure out what each did. Start with the working version, apply one change at a time, and see which breaks it. That should make it easy to figure out why. Also, ListView has been deprecated for almost a decade at this point. – Gabe Sechan Commented Mar 4 at 4:43
Add a comment  | 

1 Answer 1

Reset to default 0

I think I found the solution. I rebuilt the layout copying each control to the new layout with a few adjustments. It looked better but not as before. Then I noticed the properties layoutConstrainedHeight, L.C.Width had been set on one listview. When I set it on the other it snapped into place.

I believe the reason was I changed the targetSDK when putting it on GitHub and apparently the new property is required now.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745070105a283226.html

最新回复(0)