Project

General

Profile

Download (2.1 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / helpers / TransparentImageButton.java @ 7bb30586

1 344f290c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 1c327853 Leszek Koltunski
// 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 344f290c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10 55e6be1d Leszek Koltunski
package org.distorted.helpers;
11 344f290c Leszek Koltunski
12
import android.annotation.SuppressLint;
13
import android.content.Context;
14
import android.util.TypedValue;
15
import android.widget.LinearLayout;
16
17 464ade4a leszek
import androidx.appcompat.widget.AppCompatImageButton;
18 344f290c Leszek Koltunski
19
///////////////////////////////////////////////////////////////////////////////////////////////////
20
21
@SuppressLint("ViewConstructor")
22 464ade4a leszek
public class TransparentImageButton extends AppCompatImageButton
23 344f290c Leszek Koltunski
{
24 464ade4a leszek
  public TransparentImageButton(Context context, int icon, LinearLayout.LayoutParams params)
25 8d1da3f1 Leszek Koltunski
    {
26
    super(context);
27
28
    setLayoutParams(params);
29
    setPadding(0,0,0,0);
30 464ade4a leszek
    setImageResource(icon);
31
    setScaleType(ScaleType.FIT_CENTER);
32 8d1da3f1 Leszek Koltunski
33
    TypedValue outValue = new TypedValue();
34
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true);
35
    setBackgroundResource(outValue.resourceId);
36
    }
37 ea036986 Leszek Koltunski
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 344f290c Leszek Koltunski
}