Posts

Showing posts with the label Rounded Corners

Android Button With Rounded Corners, Ripple Effect And No Shadow

Answer : I finally solved it with below code. This achieve rounded corners for button. Also, for Android Version >= V21, it uses ripple effect. For earlier Android version, button color changes when it is clicked, based on android:state_pressed, android:state_focused , etc. In layout xml file: <Button style="?android:attr/borderlessButtonStyle" android:id="@+id/buy_button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:background="@drawable/green_trading_button_effect" android:textColor="@android:color/white" android:text="BUY" /> For button onclick ripple effect (Android >= v21) : drawable-v21/green_trading_button_effect.xml <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android...

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...