It changes its position with lesser width.
I want it standard for all screens.
You may try this below code.change your src file in imageView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:layout_margin="@dimen/_15sdp"
app:cardBackgroundColor="@color/com_facebook_blue"
app:cardCornerRadius="@dimen/_15sdp"
app:cardElevation="@dimen/_5sdp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="10dp"
android:src="@drawable/ic_checkbox_selected" />
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
I hope this can help You!
Thank You.
You Can Use This Code
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
CardView is inherited from FrameLayout, so you can make something like:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_margin="@dimen/margin_normal"
android:src="@drawable/ic_warning" />
But for more accuracy and flexibility i propose this variant:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin_normal"
android:src="@drawable/ic_warning" />
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.