1

I have two views ImageView and ViewStub between some other views. ViewStub contains a button, which I want to inflate in the main layout. Even If I keep the elevation of both i .e.ImageView and ViewStub the same (2dp). ImageView is getting elevation and is above the parent that is card view. But ViewStub is behind the card view.

If I remove ViewStub and place the button directly there, then Button is getting elevation but Placing ViewStub is causing the problem with elevation

This is the main layout in which I want to inflate the ViewStub.

< Have some other views there ....

<ImageView
    android:id="@+id/imageView"
    android:layout_width="@dimen/_60sdp"
    android:layout_height="@dimen/_60sdp"
    android:layout_centerVertical="true"
    android:layout_marginStart="@dimen/_16sdp"
    android:elevation="@dimen/_2sdp"
    app:srcCompat="@drawable/popcorn1" />

<ViewStub android:id="@+id/stub"
    android:layout_width="@dimen/_32sdp"
    android:layout_height="@dimen/_32sdp"
    android:layout="@layout/add_button"
    android:elevation="@dimen/_20sdp"
    android:layout_alignParentEnd="true"
    android:layout_centerVertical="true"
    android:layout_marginEnd="@dimen/_22sdp"
    />
 ..../>

This is an add_button.xml file

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
    android:id="@+id/addItemButton"
    android:layout_width="@dimen/_32sdp"
    android:layout_height="@dimen/_32sdp"
    android:background="@drawable/card_edge"
    android:drawableTop="@drawable/baseline_add_24_0"
    android:paddingTop="@dimen/_7sdp"
    />

This is what I am getting.

https://imghostr.com/PxBxKSxY Screen Shot

I want this round Button on the top of cardView like the imageView on the left side.

burhan sabir
  • 51
  • 1
  • 9

0 Answers0