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 androidx.appcompat.widget.AppCompatImageButton;
|
18
|
|
19
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
20
|
|
21
|
@SuppressLint("ViewConstructor")
|
22
|
public class TransparentImageButton extends AppCompatImageButton
|
23
|
{
|
24
|
public TransparentImageButton(Context context, int icon, LinearLayout.LayoutParams params)
|
25
|
{
|
26
|
super(context);
|
27
|
|
28
|
setLayoutParams(params);
|
29
|
setPadding(0,0,0,0);
|
30
|
setImageResource(icon);
|
31
|
setScaleType(ScaleType.FIT_CENTER);
|
32
|
|
33
|
TypedValue outValue = new TypedValue();
|
34
|
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
|
35
|
setBackgroundResource(outValue.resourceId);
|
36
|
}
|
37
|
|
38
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
|
40
|
public TransparentImageButton(Context context, LinearLayout.LayoutParams params)
|
41
|
{
|
42
|
super(context);
|
43
|
|
44
|
setLayoutParams(params);
|
45
|
setPadding(0,0,0,0);
|
46
|
|
47
|
TypedValue outValue = new TypedValue();
|
48
|
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
|
49
|
setBackgroundResource(outValue.resourceId);
|
50
|
}
|
51
|
}
|