【问题标题】:Shrink ripple effect收缩波纹效果
【发布时间】:2018-12-09 19:42:38
【问题描述】:

我在 Github 有以下项目:https://github.com/Ali-Rezaei/PadLayout

它包括一个名为fragment_dialpad_animation 的布局(用于拨号盘4):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageButton
        android:id="@+id/num_pad_btn"
        android:layout_width="@dimen/call_button_width"
        android:layout_height="@dimen/call_button_height"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="20dp"
        android:background="@drawable/circle_blue"
        android:src="@drawable/ic_dialpad_white_24dp"
        tools:ignore="ContentDescription" />

    <LinearLayout
        android:id="@+id/number_pad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#FFF"
        android:orientation="vertical">

        <com.github.ali.android.client.customview.view.PadLayout
            android:id="@+id/padLayout"
            style="@style/PadLayoutStyle.Animation"
            android:layout_width="match_parent"
            android:layout_height="320dp"
            custom:numColumns="3"
            custom:numRows="4">

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button1"
                style="@style/PadButtonStyle.Ripple"
                custom:letterGone="false"
                custom:numberText="1" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button2"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="ABC"
                custom:numberText="2" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button3"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="DEF"
                custom:numberText="3" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button4"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="GHI"
                custom:numberText="4" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button5"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="JKL"
                custom:numberText="5" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button6"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="MNO"
                custom:numberText="6" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button7"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="PQRS"
                custom:numberText="7" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button8"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="TUV"
                custom:numberText="8" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button9"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="WXYZ"
                custom:numberText="9" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button10"
                style="@style/PadButtonStyle.Ripple"
                custom:letterGone="false"
                custom:numberText="*" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button11"
                style="@style/PadButtonStyle.Ripple"
                custom:letterText="+"
                custom:numberText="0" />

            <com.github.ali.android.client.customview.view.DialPadKey
                android:id="@+id/button12"
                style="@style/PadButtonStyle.Ripple"
                custom:letterGone="false"
                custom:numberText="#" />

        </com.github.ali.android.client.customview.view.PadLayout>

        <include
            layout="@layout/call_button"
            android:id="@+id/call_button"
            android:layout_width="@dimen/call_button_width"
            android:layout_height="@dimen/call_button_width"
            android:layout_gravity="center"
            android:layout_marginBottom="16dp" />

    </LinearLayout>

</RelativeLayout>

它具有连锁反应:

<?xml version="1.0" encoding="utf-8"?>
<!-- unbounded ripple effect ?android:attr/selectableItemBackgroundBorderless -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/dialpad_button_pressed" />

目前涟漪效应的大小太大。有什么办法可以缩小涟漪效应吗?

【问题讨论】:

    标签: android rippledrawable


    【解决方案1】:

    默认情况下,RippleDrawable 的半径是根据其容器的大小自动计算的。您可以使用radius 属性来设置自己的大小。

    <?xml version="1.0" encoding="utf-8"?>
    <!-- unbounded ripple effect ?android:attr/selectableItemBackgroundBorderless -->
    <ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="@color/dialpad_button_pressed" android:radius="56dp" />
    

    见:https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html#attr_android:radius

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多