2017-05-16 30 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> 

答えて

関連する問題