Fix left margin in landscape mode

This commit is contained in:
Rafał Borcz 2019-06-14 12:11:02 +02:00
parent 1e7df8928c
commit 60678debfa
3 changed files with 13 additions and 8 deletions

View file

@ -15,6 +15,8 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewTreeObserver
import android.view.animation.AlphaAnimation
import android.widget.RelativeLayout
import androidx.core.view.marginLeft
import androidx.core.view.updateMargins
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.chip.Chip
import io.github.wulkanowy.materialchipsinput.util.navBarHeight
@ -95,12 +97,12 @@ internal class DropdownListView @JvmOverloads constructor(context: Context, attr
val coordinators = IntArray(2)
chipInput.getLocationInWindow(coordinators)
val layoutParams = layoutParams as MarginLayoutParams
layoutParams.topMargin = coordinators[1] + chipInput.height
layoutParams.bottomMargin = rootView.height - rect.bottom
setLayoutParams(layoutParams)
(layoutParams as MarginLayoutParams).updateMargins(
top = coordinators[1] + chipInput.height,
bottom = rootView.height - rect.bottom,
left = if (rect.left > 0) rect.left else marginLeft
)
requestLayout()
startAnimation(AlphaAnimation(0.0f, 1.0f).apply { duration = 200 })
visibility = VISIBLE
}

View file

@ -6,7 +6,7 @@
android:background="?attr/selectableItemBackground"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
<ImageView
android:id="@+id/avatar"
android:layout_width="40dp"
android:layout_height="40dp"

View file

@ -14,7 +14,10 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="io.github.wulkanowy.materialchipsinput.sample.MainActivity">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />