Reputation: 689
Coming from Xcode, I'm really confused with Android Studio. I want to do such a simple thing as putting one view above another, but for some reason, the view I want to the front ends up in the back:
imageButton
should be in front of chapter1
but no matter how I arrange the hierarchy it still ends up in the back. Should I add imageButton as a subview
to chapter1
? Should I surround the items with a container? In Xcode, you just put one view on top of another. So much simpler, or am I missing something?
Upvotes: 0
Views: 966
Reputation: 11
You can achieve that by using FrameLayout. In FrameLayout you can put views on top of each other with the last view under the hierarchy shown on top. To get ImageButton in front of Button view:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
/>
Upvotes: 0
Reputation: 689
OK, found an answer now: Android ConstraintLayout - Put one view on top of another view
For imageButton
make sure that you add xml:
android:elevation="2dp"
Upvotes: 1