Skip to content

Commit

Permalink
增加了低版本水波纹背景的替代图
Browse files Browse the repository at this point in the history
  • Loading branch information
Kale committed Apr 27, 2018
1 parent 6040e25 commit cfdc9c3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
36 changes: 31 additions & 5 deletions app/src/main/res/drawable/ripple_blue_bg.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android"
>

</shape>
<!-- 低版本显示不了水波纹,这里用了一个形状来代替 -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<shape
android:innerRadius="15px"
android:shape="ring"
android:thickness="4px"
android:useLevel="false"
>

<solid android:color="@color/colorAccent" />
</shape>
</item>

<item
android:bottom="20px"
android:left="20px"
android:right="20px"
android:top="20px"
>
<shape android:shape="oval">
<size
android:width="20px"
android:height="20px"
/>

<solid android:color="@color/colorPrimary" />
</shape>
</item>
</layer-list>
1 change: 1 addition & 0 deletions app/src/main/res/layout/ripple_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/ripple_blue_bg"
android:contentDescription="原生方式,低版本不显示水波纹"
/>

<kale.ui.view.SelectorTextView
Expand Down
1 change: 1 addition & 0 deletions lib/src/main/java/kale/injection/SelectorInjection.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ private void setSelectorDrawableToView() {
}

if (showRipple && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// https://blog.csdn.net/AwayEagle/article/details/52583913
RippleDrawable ripple = (RippleDrawable) view.getResources().getDrawable(R.drawable.si_ripple);
assert ripple != null;

Expand Down

0 comments on commit cfdc9c3

Please sign in to comment.