summaryrefslogtreecommitdiff
path: root/vdrmanager/app/src/main/java/de/androvdr/widget/SquareButton.java
blob: 6c3ad29f3d9b09537a81a250a823eeede39c1493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package de.androvdr.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;

public class SquareButton extends FontAwesomeButton {

	public SquareButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public SquareButton(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public SquareButton(Context context) {
		super(context);
	}



	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

		//Get canvas width and height
		int w = MeasureSpec.getSize(widthMeasureSpec);
		int h = MeasureSpec.getSize(heightMeasureSpec);

		w = Math.min(w, h);
		h = w;

		setMeasuredDimension(w, h);
	}
}