JJJones_3860
JJJones_3860

Reputation: 1542

Android Studio 3.5 What happened to my buttons?

I created 3 ImageButtons that look find in my layout in Android Studio, but when the app is loaded onto my phone, the buttons are tiny.

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <AutoCompleteTextView
        android:id="@+id/CountryList"
        android:completionThreshold="1"
        app:layout_constraintEnd_toStartOf="@id/clearCountryButton"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:hint="Country"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginBottom="4dp"
        android:layout_width="0dp"
        android:layout_height="wrap_content" />

    <ImageButton
        android:id="@+id/clearCountryButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="16dp"
        app:layout_constraintBottom_toBottomOf="@id/CountryList"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toRightOf="@id/CountryList"
        tools:src="@android:drawable/ic_input_delete" />

I left off the next two AutoCompleteTextView and ImageButton pairs for brevity.

Here is how it looks in Android Studio...

enter image description here

And here is how it looks on my phone...

enter image description here

I can't see what I am doing wrong. Anyone?

Jeff

Upvotes: 1

Views: 186

Answers (2)

A Farmanbar
A Farmanbar

Reputation: 4788

Try use

app:srcCompat="@drawable/ic_input_delete"

instead of using

tools:src="@android:drawable/ic_input_delete"

or

android:src="@android:drawable/ic_input_delete"

it's a deprecated method for drawing vector drawables and even Android studio suggests to change it.

Upvotes: 1

Rafael Mercado
Rafael Mercado

Reputation: 11

Replace tools:src="@android:drawable/ic_input_delete" with android:src="@android:drawable/ic_input_delete"

Example:

<ImageButton
        android:id="@+id/clearCountryButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="16dp"
        app:layout_constraintBottom_toBottomOf="@id/CountryList"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toRightOf="@id/CountryList"
        android:src="@android:drawable/ic_input_delete" />

Upvotes: 1

Related Questions