android


How to have an image embedded on an image button scale to the size of the image


I am attempting to create a calculator app, I would like to use an image button to allow the user to select what they want to calculate. I want to use this image for the 0 button (zero button image). Currently when I add the image to the user interface, it is cropped like this (cropped zero image). Is there a way to allow the image to scale to the size of the button when I resize the button? Thank you!
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.lontronix.calculator.Calculator">
<TextView
android:id="#+id/textView"
android:layout_width="500dp"
android:layout_height="125dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="#string/Filler_Text"
android:textSize="35pt" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="250dp"
android:layout_height="150dp"
app:srcCompat="#drawable/zero"
android:layout_marginStart="50dp"
android:layout_marginBottom="42dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
write these properties on your imageView.
android:adjustViewBounds="true"
android:scaleType="fitXY"
Or you can try a different scaleType, see below:
https://robots.thoughtbot.com/android-imageview-scaletype-a-visual-guide

Related Links

Integrating a Codec to Android multimedia framework
Click on image do not respond on first time, need to click it again, Why?
How to refresh GridView without moving it?
How to publish a paid app to play sore
What exactly are the numbers in logcat's GC_CONCURRENT saying? [duplicate]
Am newbie to JSON and android as well, Am not getting how to parse the inside “options” JSONArray
Mifare classic - what is the address byte for, and how does it work
Not able to login in facebook with facebook sdk 3.0 loginbutton button using other users, though it is working with developers login credentials
How to write text more than 10 letters using Canvas and paint on map?
Strange results while compressing batch of pictures with libjpegturbo
Android Studio: apache.http.entity.mime does not exist
What color should have an icon when used in Action Bar
TextViews with dividers in between them
google inapp details in android
TWITTER4J - Filter tweets by location: tweets outside defined area
Monitoring app launches on android

Categories

HOME
service-worker
scikit-learn
string
amp-html
flex
mysql-workbench
toolbox
socket.io
graphics
opendj
access
mips
onclick
fosrestbundle
32bit-64bit
google-chrome-app
windows-ce
radgridview
symmetricds
gruntfile
entitymanager
scsi
intershop
wolframalpha
imessage
poedit
monit
beta
xcode-ui-testing
onload
has-and-belongs-to-many
intersystems-cache
inversion-of-control
sinch
paperjs
scrollview
dumpbin
twos-complement
ideascript
sessionstorage
apns-php
azure-arm
xv6
placeholder
contract
photos
vaadin-charts
xbmc
textsum
ntvs
clarifai
magic-draw
oracleclient
dt
cup
flac
gameplay-kit
choice
materialized-path-pattern
usart
autosar
hadoop-2.7.2
dotnetnuke-7
appscale
cda
ikiwiki
gocql
computer-architecture
zen-cart
apache-commons-daemon
canvg
grouping-sets
packet-sniffers
boost-program-options
mruby
iiop
android-vibration
punycode
appserver
template-deduction
parallel-testing
alternate
paste
cfcache
gwt-openlayers
spring-3
bin
printdialog
octal
joomla3.1
panda3d
qtconcurrent
veracity
wcf-configuration
pyunit
objectquery
multiplexing
predicatebuilder
isa-swizzling
stress
box2d-iphone
procedures
rowlex
opml
spread
wcf-instancing
cldc
escrow
entitykey
unmanagedresources
contentpresenter
blind

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App