对话框中按钮的涟漪效果不平滑

时间:2018-05-24 03:37:28

标签: android android-layout dialog rippledrawable

我像这样创建Dialog

布局dialog_app_rating

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="vertical"
    android:paddingEnd="@dimen/spacing_large"
    android:paddingStart="@dimen/spacing_large"
    tools:ignore="MissingPrefix">

    <TextView
        fontPath="@string/font_roboto_bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/spacing_normal"
        android:text="@string/rating_remind_title"
        android:textColor="@color/text_blue"
        android:textSize="@dimen/font_large"
        tools:text="Rate my app" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/spacing_small"
        android:text="@string/rating_remind_msg"
        android:textSize="@dimen/font_normal"
        tools:text="Rate if it is useful" />

    <com.iarcuschin.simpleratingbar.SimpleRatingBar
        android:id="@+id/app_rating_rb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="@dimen/spacing_normal"
        app:srb_borderColor="@color/grey"
        app:srb_fillColor="@color/pink"
        app:srb_numberOfStars="5"
        app:srb_rating="5"
        app:srb_starBorderWidth="1"
        app:srb_starSize="@dimen/spacing_larger"
        app:srb_starsSeparation="@dimen/spacing_small"
        app:srb_stepSize="1" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/spacing_normal">

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/not_show_again_btn"
            style="?attr/buttonBarNeutralButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/text_button_height"
            android:text="@string/rating_remind_dont_show_again"
            android:textColor="@color/text_blue" />

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/send_btn"
            style="?attr/buttonBarNeutralButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/text_button_height"
            android:layout_gravity="end"
            android:text="@string/send"
            android:textColor="@color/text_blue" />
    </FrameLayout>

</LinearLayout>

RatingDialog的代码:

class RatingDialog extends Dialog {
    @BindView(R.id.app_rating_rb) SimpleRatingBar mAppRatingBar;
    @BindView(R.id.not_show_again_btn) View mNotAgainBtn;
    @BindView(R.id.send_btn) View mSendBtn;

    RatingDialog(@NonNull Context context) {
        super(context, R.style.DialogTheme);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.dialog_app_rating);
        ButterKnife.bind(this, this);

        mNotAgainBtn.setOnClickListener(this);
        mSendBtn.setOnClickListener(this);
    }

    @Override
    protected void onStart() {
        super.onStart();

        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    // Other implementation...
}

DialogTheme中的styles.xml

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowSoftInputMode">stateUnchanged|adjustPan</item>
    <item name="colorAccent">@color/pink</item>
</style>

它只有一些文字,评级栏和2个按钮。默认情况下,按钮触摸时会出现涟漪效应

问题是在Dialog中使用时,涟漪效应不平滑。它使背景变暗,显示波纹并延迟一点然后完成,就像跳过帧一样。我也尝试过对其他对话框的影响,但问题是一样的。对于仅Dialog的动画或者我的配置有问题,Android是否设置为低优先级,我可以修复它吗?

提前致谢

0 个答案:

没有答案