- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有不同 draw9patch png
作为背景的按钮。目前按钮由 selector
控制,看起来像这样:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/disabled" android:state_enabled="false"/>
<item android:drawable="@drawable/focused" android:state_focused="true"/>
<item android:drawable="@drawable/default"/>
</selector>
对于 Android Lollipop,他们有一个用于触摸效果的 RippleDrawable
,如下所示:
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight">
<item>
...
</item>
</ripple>
关于新的触摸涟漪效果:
1:我可以将draw9patch设置为RippleDrawable
的背景吗?
2:我要如何适应上述两种不同的xml我想遵循Material design?我是否必须为新的 RippleDrawable
创建一个新的文件夹/布局 xml?
最佳答案
1) 是的。有关如何合成图层的更多详细信息,请参阅 RippleDrawable 的文档,但基本上你想要:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:drawable="@drawable/yourninepatch" />
</ripple>
或者也以干净的方式处理禁用状态,您可能想要:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item>
<selector>
<item android:state_enabled="false">
<nine-patch
android:src="@drawable/yourninepatch"
android:alpha="?android:attr/disabledAlpha" />
</item>
<item>
<nine-patch android:src="@drawable/yourninepatch" />
</item>
</selector>
</item>
</ripple>
2) 是的,您应该将您的波纹 XML 放在 drawable-v21 中。
关于android - Lollipop RippleDrawable 与 Pre-Lollipop 的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24607339/
我有这样的看法 和 ripple.xml 一样 一切正常。当我触摸 View 时,它会给我涟漪效应。我正在寻找的是从代码中重复启动 View 上的涟漪动画。将其显示为不确定的进度。所
我想在代码中动态创建涟漪。 代码: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buyB
我正在尝试创建分段按钮控件,并且我为每个分段使用了一个可绘制对象。
我创建了一个 RippleDrawable,如下所示。但是我不能改变 RippleDrawable 的角半径。它没有像 setCornerRadii(float[] f) 这样的方法。 public
drawable-v21/ripple.xml: TextView : 如果我想将 RippleDrawable 设置为 TextView,我必须设置 android:backgro
我正在寻找这里提到的 RippleDrawable 的源代码 https://developer.android.com/preview/material/animations.html#touch
我试图通过 android 的 RippleDrawable 方法应用 RippleEffect,我首先将 drawable 中的波纹定义为:- 文件名为ugb.xml 然后我尝试将它作为我的抽屉导航
我有一个布局,上面有一个 KenBurnsView 和一个 ImageView(只是一个切换按钮)。当我单击按钮时,会生成一个 Ripple,但绘制在 KenBurnsView 下方。 以前,当我用
我有一个在代码中创建 RippleDrawables 的方法 public class StateApplier { @TargetApi(Build.VERSION_CODES.LOL
我正在尝试将 RippleDrawable 设置为 ListView 行的背景。使用 view.setBackgroundResource(R.drawable.ripple) 时一切正常。尝试时 v
首先,我的目标 API 是 22 (Android L)。一切正常,直到我将目标 API 降低到 19 以支持 Android 4.4 (Kitkat)。现在我收到了这个奇怪的错误。该应用程序不会崩溃
引用 RippleDrawable for Android L,https://developer.android.com/reference/android/graphics/drawable/Ri
我正在使用第三方库,有一种方法使用 DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);。当我在 android 5.0+ 上测试
Android 应用程序意外关闭并在 log-cat 中给出以下错误。 01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class
一段时间以来,我一直在尝试追踪这个问题。我想我前段时间确实找到了解释。不幸的是,它在某处的代码注释中丢失了。 我正在尝试用 Java 创建一个 Material Borderless-Button。首
我继承了 Button。在该类中,我尝试以编程方式更改颜色。 RippleDrawable draw = (RippleDrawable) getContext().getApplicationCon
我尝试在我的手机上运行它,但只有一个白屏。无法弄清楚这里的错误... Java package make.myapplication; import android.os.Bundle; i
我正在开发一款在大型设备上使用双 Pane 布局的应用程序,类似于详细说明 here .布局概要;一个 Pane 包含选项列表,而另一个 Pane 将显示有关从另一个 Pane 中选择的选项的详细信息
范围 RippleDrawable 内部有 selector 作为 item。它有效。 + 问题 无法使
我有不同 draw9patch png 作为背景的按钮。目前按钮由 selector 控制,看起来像这样: 对于 Android Lollipop,他们有一个用于触摸效果的
我是一名优秀的程序员,十分优秀!