Image view is hiding under the button what changes I can do so that the image view can be above the button view pager also have bottom padding so that button can properly accommodate. The image is showing on the other parts but not above the button.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:orientation="vertical"
tools:context=".McqActivity"
android:id="@ id/fragment"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageView
android:id="@ id/starFirst"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_baseline_star_24"
/>
<com.google.android.material.button.MaterialButton
android:id="@ id/right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@ id/questions_view_frag"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
android:orientation="horizontal"
android:paddingBottom="20dp"
android:paddingTop="50dp"
>
</androidx.viewpager2.widget.ViewPager2>
</androidx.constraintlayout.widget.ConstraintLayout>
CodePudding user response:
layout_constraintBottom_toBottomOf
and other layout_constraint...
won't work inside RelativeLayout
, these are desired to work with ConstraintLayout
as strict parent. if you want to align two View
s next to/below/above inside RelativeLayoyut
you have to use other attributes, e.g.
android:layout_below="@ id/starFirst"
android:layout_above="@ id/starFirst"
android:layout_toRightOf="@id/starFirst"
android:layout_toLeftOf="@id/starFirst"
note that every attr which starts with layout_
is desired to be read by strict parent, not by View
which have such attrs set. every ViewGroup
have own set of such
edit: turned out that this is an elevation
case/issue (Z axis), so useful attributes are
android:translationZ="100dp"
android:elevation="100dp"