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

set grid layout column to half the width in android
Changes to android widget not loading
Resize the height of the ListView Row in Android?
Android Nexus 10 Emulator not running properly [duplicate]
Android SQLite Create Table Issue
Android: App has stopped working issue
I want to create a compiler in android for C language like C4droid app
Titanium Studio cannot install Android SDK
Service and background music codes -updated-
Specify filename in ContentProvider
ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams
Why service is re-started after the application process is killed
org.json.JSONException: Value < of type java.lang.String cannot be converted to JSONObject
how to solve android.os.NetworkOnMainThreadException in json [duplicate]
Android ndk-build: “error: undefined reference to 'std::__throw_bad_alloc()”
How to add Background processing permission to BB10 App ported from android?

Categories

HOME
uml
phantom-dsl
search
eslint
ggplot2
r-googlesheets
ado.net
jetty
missing-data
frontend
opengl-3
computer-science
fabric.io
pcl-crypto
fhir
distribution
rtf
jsonpath
tput
searchview
microsoft-dynamics-nav
swagger-2.0
googlebot
libigl
object-storage
dynamically-generated
twiml
complex-numbers
mockjax
git-squash
erb
login-script
modalviewcontroller
nohup
odroid
ods
apriori
angular-http
photos
httr
jide
robomongo
user-defined-fields
fclose
facebook-pixel
dbcontext
zenhub
arq
context-switch
java-6
ngmaterial
avx
jqchart
mathcad
sandcastle
reachability
uicolor
windows-azure-queues
dup
cifilter
omniauth-facebook
lua-telegram-bot
cda
toast
asyncdisplaykit
highland.js
spring-retry
java-money
video-player
amiga
dronekit-android
airbrake
code-documentation
cryptographichashfunction
mass-assignment
rapidsvn
primitive-types
sip-server
crowd
punycode
grails-domain-class
reflector
xml-dsig
openargs
mysql-error-1044
dtmf
ice-cube
tlf
extreme-programming
saleslogix
correlated-subquery
window-decoration
listactivity
google-ajax-api
cac
vs-android
non-clustered-index
tabpanel
pos-for-.net
blender-2.49
qtabbar
commercial-application

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