CalebM
CalebM

Reputation: 23

Image pressed button changing size

I realize this has been asked multiple times, but my image is changing size when it is pressed (which is should be the same size, but a different image). I've previously tried setting the size of the button in java, but it didn't work either. Here is my code.

XML Selector

<?xml version="1.0" encoding="utf-8"?>

    <selector xmlns:android="http://schemas.android.com/apk/res/android">

         <item android:state_pressed="true" 
           android:drawable="@drawable/testbuttonpressed" /> <!-- pressed -->

         <item android:drawable="@drawable/testbutton" /> <!-- default -->

    </selector>

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/backtest1">

  <Button
    android:id="@+id/start_button"
    android:layout_width="225px"
    android:layout_height="55px"
    android:layout_marginTop="10dp"
    android:layout_gravity="center"
    android:text="@string/start"
        android:background="@drawable/buttonsxml"
   />

</LinearLayout>

Upvotes: 0

Views: 908

Answers (1)

CalebM
CalebM

Reputation: 23

It turns out my pictures were a pixel off...

Upvotes: 1

Related Questions