-1

I'm looking for a button just like this (transparent background and when clicked it becomes gray):Image of the component

Mordechay
  • 21
  • 5

2 Answers2

1

Your question is not so clear, but here is how you can create custom or style Button

DiLDoST
  • 335
  • 3
  • 12
0

I succeeded. The solution is:

xml(button_category_template):

<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#000000"
android:textSize="20sp"
 />

java(MainActivity):

public class startActivity extends AppCompatActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);

    Button btn = (Button)getLayoutInflater().inflate(R.layout.button_category_template, null);
    lnr = findViewById(R.id.layoutApp);
        lnr.addView(btn);
   }
}

It may be possible to do it in a simpler way, but in my project I used it this way.

Mordechay
  • 21
  • 5