Brianjs
Brianjs

Reputation: 2239

Setting ImageView source not working correctly

I am loading a new image into an imageview when the stop and play button is pressed. They toggle back and forth. However when I set the image source in my code is appears really wrong.

Before

enter image description here

Then I call

bottomBar.setImageResource(R.drawable.bottombuttonsstop);

End Result

enter image description here

Layout XML

<LinearLayout
    android:id="@+id/bottomBarBox"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >
    <ImageView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:background="@drawable/bottombuttons"
        android:layout_height="wrap_content" />
</LinearLayout>

Obviously this is not loading correctly for some reason, any ideas?

Upvotes: 0

Views: 280

Answers (1)

Seraph
Seraph

Reputation: 562

Try to call setBackgroundResource instead of setImageResource or set android:src in a layout file

Upvotes: 1

Related Questions