1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.helpers;
|
11
|
|
12
|
import android.annotation.SuppressLint;
|
13
|
import android.content.Context;
|
14
|
import android.util.TypedValue;
|
15
|
import android.widget.LinearLayout;
|
16
|
|
17
|
import com.google.android.material.button.MaterialButton;
|
18
|
|
19
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
20
|
|
21
|
@SuppressLint("ViewConstructor")
|
22
|
public class TransparentButton extends MaterialButton
|
23
|
{
|
24
|
public TransparentButton(Context context, int resId, float textSize)
|
25
|
{
|
26
|
this(context, resId, textSize, 1.0f);
|
27
|
}
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public TransparentButton(Context context, int resId, float textSize, float weight)
|
32
|
{
|
33
|
super(context);
|
34
|
|
35
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, weight);
|
36
|
|
37
|
setLayoutParams(params);
|
38
|
setPadding(0,0,0,0);
|
39
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
40
|
setText(resId);
|
41
|
|
42
|
TypedValue outValue = new TypedValue();
|
43
|
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
|
44
|
setBackgroundResource(outValue.resourceId);
|
45
|
}
|
46
|
}
|