Skip to content

Commit

Permalink
[Teacher][RC-1.9.1] Fix student context page having full height views (
Browse files Browse the repository at this point in the history
…#431)

On Android 10, adding a view during runtime was having it take the entire view height. Placing it in the xml file and toggling the visibility allows the children to actually wrap_content like we want.
  • Loading branch information
CalvinKern authored Dec 11, 2019
1 parent 7db1944 commit 4fcc40e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.instructure.teacher.adapters
import android.graphics.Color
import android.os.Bundle
import android.view.*
import android.widget.LinearLayout.LayoutParams
import android.widget.TextView
import com.instructure.canvasapi2.StudentContextCardQuery.*
import com.instructure.canvasapi2.models.BasicUser
Expand Down Expand Up @@ -207,10 +206,7 @@ class StudentContextFragment : PresenterFragment<StudentContextPresenter, Studen
val visibleGradeItems = gradeItems.children.filter { it.isVisible }
if (visibleGradeItems.size == 1) {
// If there is only one grade item, add a second empty child so the first doesn't stretch to the full parent width
gradeItems.addView(
View(context),
LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f)
)
emptyGradeItemSpace.setVisible()
} else {
// Set color of last grade item
visibleGradeItems.lastOrNull()?.apply {
Expand Down
7 changes: 7 additions & 0 deletions apps/teacher/src/main/res/layout/fragment_student_context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@

</LinearLayout>

<Space
android:id="@+id/emptyGradeItemSpace"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone" />

</LinearLayout>

<TextView
Expand Down

0 comments on commit 4fcc40e

Please sign in to comment.