3

Iv've been trying to match a button solid color with its border color while also adding a ripple effect. I've have a matching border and solid color (without a ripple) but when I add the ripple it seems to add a border of its own thats slightly darker. Below are the styles and drawable,

drawable-v21/my_btn.xml

<?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="#ff0000"
    tools:ignore="NewApi">
    <item>
        <shape
            android:shape="rectangle">
            <corners
                android:radius="2dp" />
            <stroke
                android:width="1dp"
                android:color="#ff0000" />
            <solid
                android:color="#ffffff" />
        </shape>
    </item>
</ripple>

styles.xml

<style name="Border_Button">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#000000</item>
        <item name="android:textSize">14sp</item>
        <item name="android:textAllCaps">true</item>
        <item name="android:layout_marginLeft">16dp</item>
        <item name="android:layout_marginRight">16dp</item>
        <item name="android:background">@drawable/my_btn</item>
    </style>

and layout.xml

<Button
        style="@style/Border_Button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#000000"
        android:text="Click" />

Does anyone know how this border color can be overridden with the ripple or is there is some other way to achieve this (only XML preferrably)?

4

0 回答 0