<FrameLayout
android:id="@+id/flTodayTraining"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fl_today_training_bg_margin_bottom"
android:layout_marginTop="@dimen/fl_today_training_bg_margin_top"
android:layout_marginHorizontal="@dimen/fl_today_training_bg_margin_horizontal"
android:background="@drawable/today_training_bg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDaysTrained"
>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/iv_today_training_detail_height"
android:src="@drawable/male_upper_body"
android:scaleType="fitXY"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/upper_body"
android:textSize="@dimen/tv_today_training_detail_text_size"
android:textColor="@color/black"
android:paddingVertical="@dimen/tv_today_training_detail_padding_vertical"
android:gravity="center"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
That’s the cornered background of the frame layout
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners
android:radius="15dp"
/>
</shape>
As you can see in the image, it’s rounded in the bottom, but not in the top, how do I make it rounded in all corners?
Please give me an answer that works on all version, not only api 31 +
2
Answers
Instead of setting the background to the FrameLayout set it to the immediate ViewGroup. Also remove fitXy in the imageview
Create this background drawable
Very simple. Just use
cardView
see below XML code
and the result is below
pros-
card view
to show shadowI hope it’ll help you.