Posts

Showing posts with the label Material Components Android

Android - How To Disable STATE_HALF_EXPANDED State Of A Bottom Sheet

Image
Answer : The value of the half expanded ratio must be set to some value between 0 and 1 exclusive , so set this value to some very low number that is certain to be less than your peek height, say "0.0001f". With this value you should not even see the STATE_HALF_EXPANDED state. The states will fluctuate between STATE_EXPANDED and STATE_COLLAPSED . Alternate solution The solution above works and effectively disables the STATE_HALF_EXPANDED state, but it is hackish (IMO) and may break in the future. For instance, what if a reasonable value for the half expanded ratio which is somewhere between the peek height and the full height is enforced? That would be trouble. The requirements as stated by the OP is that the bottom sheet should transition between the peek height and the full height. There is no problem with the peek height, but the OP specifies isFitToContents = false to get to the full height. (I assume that his bottom sheet may be shorter then the available...

Android - ImageView With Rounded Only One Corner

Image
Answer : You can use the Material Components Library. With the version 1.2.0-alpha03 there is the new ShapeableImageView . Just use in your layout: <com.google.android.material.imageview.ShapeableImageView app:srcCompat="@drawable/..." ../> And in your code apply the ShapeAppearanceModel with: float radius = getResources().getDimension(R.dimen.default_corner_radius); imageView.setShapeAppearanceModel(imageView.getShapeAppearanceModel() .toBuilder() .setTopRightCorner(CornerFamily.ROUNDED,radius) .setBottomLeftCorner(CornerFamily.ROUNDED,radius) .build()); You can use this library and put your ImageView inside the Layout https://github.com/JcMinarro/RoundKornerLayouts and can set the radius for specific corners like this containerLayout.setCornerRadius(2f, CornerType.ALL); containerLayout.setCornerRadius(2f, CornerType.BOTTOM_LEFT); Other choices public final enum class CornerType private constructor() : kotli...