Skip to content

Commit

Permalink
Make view match width and height values if any of the two is set as W…
Browse files Browse the repository at this point in the history
…RAP_CONTENT (FIX)!
  • Loading branch information
slaviboy committed Apr 11, 2020
1 parent e96990a commit 6d08d5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
11 changes: 5 additions & 6 deletions app/src/main/res/layout/color_picker_hsv_rectangular.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
<com.slaviboy.colorpicker.windows.rectangular.RectangularSV
android:id="@+id/rectangularSV"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="wrap_content"
app:corner_radius="0.05vh"
app:layout_constraintBottom_toBottomOf="@+id/guideline_windows_texts"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="@+id/guideline_sv_h"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -41,10 +40,10 @@
android:layout_height="0dp"
android:layout_marginRight="5dp"
app:corner_radius="0.05vh"
app:layout_constraintBottom_toBottomOf="@+id/guideline_windows_texts"
app:layout_constraintBottom_toBottomOf="@+id/rectangularSV"
app:layout_constraintLeft_toLeftOf="@+id/guideline_sv_h"
app:layout_constraintRight_toRightOf="@+id/guideline_h_a"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@+id/rectangularSV"
app:selector_radius="0.06vh"
app:selector_stroke_width="0.03vh"
app:type="vertical" />
Expand All @@ -56,10 +55,10 @@
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
app:corner_radius="0.05vh"
app:layout_constraintBottom_toBottomOf="@+id/guideline_windows_texts"
app:layout_constraintBottom_toBottomOf="@+id/rectangularSV"
app:layout_constraintLeft_toLeftOf="@+id/guideline_h_a"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@+id/rectangularSV"
app:selector_radius="0.06vh"
app:selector_stroke_width="0.03vh"
app:type="vertical" />
Expand Down
18 changes: 6 additions & 12 deletions colorpicker/src/main/java/com/slaviboy/colorpicker/window/Base.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,14 @@ abstract class Base : View {
layoutParams.width = newWidth
layoutParams.height = newHeight
layoutParams = layoutParams

// call since the layout params are changed
this.afterMeasured {
afterMeasuredInit()
}
} else {
afterMeasuredInit()
}
}

fun afterMeasuredInit() {
onInitBase()
update()
onRedraw()
// since change is made measure again and initialize
this.afterMeasured {
onInitBase()
update()
onRedraw()
}
}

/**
Expand Down

0 comments on commit 6d08d5c

Please sign in to comment.