2017-05-16 1 views
0

계산기 앱을 만들려고합니다. 사용자가 원하는 것을 선택할 수 있도록 이미지 단추를 사용하고 싶습니다. 0 버튼 (zero button image)에이 이미지를 사용하고 싶습니다. 현재 사용자 인터페이스에 이미지를 추가하면 다음과 같이 자릅니다 (cropped zero image). 단추의 크기를 조정할 때 이미지가 단추의 크기로 확대되도록하는 방법이 있습니까? 고맙습니다!이미지 단추에 포함 된 이미지를 이미지 크기에 맞게 조절하는 방법

코드 :

<?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> 

답변

관련 문제