Масштабирование кастомного view

при создании view типа "аналоговый индикатор" столкнулся с проблемой некорректного масштабирования на экране.ImageView с цифрами должна перемещаться вверх-вниз, а в ячейке отображаться текущее значение. но при запуске приложения ImageView по высоте сжимается. можно ли сделать так, чтобы было видно только ячейку с цифрой, остальное скрыть? имея при этом элемент размером с ячейку. на скринах видно как это отображается в xml элемента и в activity_main.xml

как это выглядит в spin_digits layout

как это выглядит в activity_main

код spin_digits.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
    android:id="@+id/digits"
    android:layout_width="wrap_content"
    android:layout_height="520dp"
    android:layout_centerHorizontal="true"
    android:src="@drawable/dig3"
    android:translationY="-231dp" />

<ImageView
    android:id="@+id/cell1"
    android:layout_width="65dp"
    android:layout_height="78dp"
    android:layout_centerInParent="true"
    android:src="@drawable/cell1" />
</RelativeLayout>

код файла SpinDigits.java

public class SpinDigits extends RelativeLayout {

Context context;
private ImageView digs1;
private float[] digits;
private Toast toast;

public SpinDigits(Context context) {
    super(context);
    this.context = context;
    init();
}

public SpinDigits(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    init();
}

public SpinDigits(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;
    init();
}

public void setNumber(int number) {
    if (number >= 0 && number < 10)
        digs1.setY(digits[number]);
    else
        digs1.setY(digits[10]);
}


private void init() {
    LayoutInflater.from(context).inflate(R.layout.spin_digits_single, this);
    ImageView cell1 = (ImageView) findViewById(R.id.cell1);
    digs1 = (ImageView) findViewById(R.id.digits);

    digits = new float[11]; //заполнение таблицы координат цифр
    for (int i = 1; i < 11; i++) {
        digits[0] = digs1.getX();
        digits[i] = digits[0] + digs1.getHeight() * i;
    }
}
}

код activity_main.xml

<?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=".MainActivity">

<com.evilstan.aviationcalculator.LightButton
    android:id="@+id/btn_test"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_below="@id/gauge1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="30dp"
    android:adjustViewBounds="true"
    android:padding="5dp"
    android:src="@drawable/off3"
    app:image_off="@drawable/off3"
    app:image_on="@drawable/on3"
    app:sound_push="@raw/click6"
    app:sound_release="@raw/click5" />

<com.evilstan.aviationcalculator.LightButton
    android:id="@+id/btn_test2"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_below="@id/gauge1"
    android:layout_alignParentStart="true"
    android:layout_marginTop="30dp"
    android:adjustViewBounds="true"
    android:padding="5dp"
    android:src="@drawable/button"
    app:image_off="@drawable/button"
    app:image_on="@drawable/button1"
    app:sound_push="@raw/click3"
    app:sound_release="@raw/click4" />

<com.evilstan.aviationcalculator.LightButton
    android:id="@+id/btn_test3"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_below="@id/gauge1"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="30dp"
    android:adjustViewBounds="true"
    android:padding="5dp"
    android:src="@drawable/off1"
    app:image_off="@drawable/off1"
    app:image_on="@drawable/on1" />

<com.evilstan.aviationcalculator.Gauge
    android:id="@+id/gauge1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    app:max_angle="360"
    app:pointer_axle="0.66"
    app:start_angle="50" />

<com.evilstan.aviationcalculator.SpinDigits
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/btn_test"
    android:layout_centerHorizontal="true" />

</RelativeLayout>

Ответы (0 шт):