Hello. I need to make these buttons. I tried to use the ImageButton and a simple Button, the result was the following (see Figure 3). My code is:

<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:orientation="horizontal" android:layout_alignParentBottom="true" android:background="@color/colorLightGray" android:padding="0dp"> <Button android:layout_margin="0dp" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/autorenew" android:drawablePadding="0dp" android:text="Check Now" /> <Button android:layout_margin="0dp" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/play" android:drawablePadding="0dp" android:text="Start serv" /> <Button android:layout_margin="0dp" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/stop" android:drawablePadding="0dp" android:text="Stop service" /> </LinearLayout> </RelativeLayout> 

But this is not very similar to what I need ... The Ripple effect is not even the same and its radius is limited.

введите сюда описание изображения

  • Try TextView instead of Button and their android:background="?android:attr/selectableItemBackground" instead of style. - eugeneek
  • It certainly looks better, but the left and right Ripple effect is limited to straight borders. I would like in the example, that would be like a circle. - Xom9ik
  • ibb.co/f1ihWS This is the result - Xom9ik
  • And so android:background="?attr/selectableItemBackgroundBorderless" ? - eugeneek
  • What you need, thank you) One question, how can I lower the picture? - Xom9ik 1:54 pm

2 answers 2

First, create an .xml file in your drawable resources. The path you need: res / drawable / ripple_effect.xml

Put this code in it:

 <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:color="#80000000" tools:targetApi="lollipop"> <item android:id="@android:id/mask"> <shape android:shape="rectangle"> <solid android:color="#f8a7a9a8" /> <corners android:radius="2dp"/> </shape> </item> </ripple> 

Then add the android: background = "@ drawable / ripple_effect" tag to the xml file with the button.

Example:

 <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/ripple_effect" android:padding="16dp" android:text="New Button" /> 

    Solution of the problem (thanks to eugeneek):

     <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true" android:background="@color/colorLightGray" android:padding="0dp"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:layout_margin="0dp" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/autorenew" android:text="Check Now" android:textSize="12sp" android:paddingTop="8dp" android:paddingBottom="4dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/play" android:text="Start service" android:textSize="12sp" android:paddingTop="8dp" android:paddingBottom="4dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:layout_weight="1" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:drawableTop="@drawable/stop" android:text="Stop service" android:textSize="12sp" android:paddingTop="8dp" android:paddingBottom="4dp" /> </LinearLayout> </RelativeLayout>