I want to create this layout
this is a cardview (gray view) and imageview(blue view) for that i use this code
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/abc_search_url_text_normal"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginBottom="3dp"
android:paddingTop="5dp"
app:cardBackgroundColor="@color/abc_input_method_navigation_guard">
</android.support.v7.widget.CardView>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:layout_marginRight="10dp"
android:scaleType="fitXY"
android:src="@drawable/abc_ratingbar_full_material" />
</FrameLayout>
but in result my image view going to back of cardview i try reletivelayout instead of framelayout but same result.
Customized CardView First, add a CardView dependency to the application-level build. gradle file. Then create a drawable background for the cards. For that, create a new drawable resource file inside the drawable folder.
CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other. The main usage of CardView is that it helps to give a rich feel and look to the UI design.
What is cardUseCompatPadding? For a more consistent UI, use cardUseCompatPadding=true. CardView adds additional padding to draw shadows on platforms before Lollipop. This may cause Cards to have different sizes between Lollipop and before Lollipop.
The CardView has by default elevation in API 21+, you can manipulate the elevation to be less than that of the ImageView
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="1dp"/>
<ImageView
android:id="@+id/image_view_user"
android:layout_width="48dp"
android:layout_height="48dp"
android:elevation="2dp"/>
in Pre 21 you can use
overlayView.bringToFront();
root.requestLayout();
root.invalidate();
This will not work in 21+ if you have different elevation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With