100 days of code D6 & 7.
Created an application that takes two photos uploaded to the drawable folder. Added a button called New Cat and when clicked, will display a photo of a different cat. First tested that my button worked by using the Log.i to display a message to the log to ensure that my button was clicked. Created the onClick function called “clickCat”. Worked very similar to the EditText, only used ImageView and typecasted the findView to ImageView. The second part was to use
image.setImageResource(R.drawable.cat2);
to set the image to the second photo upon being clicked.
You can use Properties > Scale Type to change how the photo is displayed in the screen. FitXY stretches it to the edge of the container, fitStart keeps it in proportion and aligns to top of container, Center keeps it in proportion and centers the image. Center is probably one I will use the most.
And here are my results!
Beautiful cats aren’t they?