Tilak Raj
Tilak Raj

Reputation: 1499

components overlapping on each other

Since, i am new to android, i was trying to build a scientific calculator . So in that i have an edit text which displays the results of the calculations.

Now what i was doing was to provide a button on top of it , so that , people can access the advance features of the calculator.

I read various questions regarding and tried to do that and it doesn't seem to work.

Like obviously they overlap.

But edittext comes up on top of imagebutton which makes any click event on imagebutton useless.

Code

<ImageButton
        android:contentDescription="View advance features"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:id="@+id/go_advance"
        android:scaleType="fitXY"
        android:layout_alignParentTop="@id/linearLayout"
        android:layout_alignParentBottom="@id/linearLayout"
        android:background="@drawable/round_buttons"

        />
    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">



        <EditText
            android:id="@+id/editText3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:height="225dp"
            android:textSize="24sp"
            android:gravity="end|bottom"
            android:ems="10"
            android:maxLines="2"
            android:inputType="textMultiLine"
            tools:layout_editor_absoluteX="104dp"
            tools:layout_editor_absoluteY="207dp" />

enter image description here

How would i put my imagebutton on top of edittext?

Upvotes: 1

Views: 70

Answers (1)

Valentin Baryshev
Valentin Baryshev

Reputation: 2205

I guess you are using RelativeLayout as parent layout. Place your ImageButton after LinearLayout.

<RelativeLayout>
   <LinearLayout>
        ...
        edit text, buttons etc
        ...
   </LinearLayout>
   <ImageButton/>
</RelativeLayout>

Upvotes: 1

Related Questions