rippledrawable

Set background on TextView object and maintain ripple effect

☆樱花仙子☆ 提交于 2019-12-05 17:34:50
I want to set the background of a TextView object programmatically, but also have a ripple effect for it. I can use with background set to android:selectableItemBackground , but the ripple effect gets lost, when setting the background. I also tried putting an ImageView together with the TextView in a FrameLayout . And set the image not as the background of the TextView , but as image of the ImageView : Yes, ripple is there, but it appears to be "behind" the image. Do I need to create a RippleDrawable from the bitmapfor the background? How would I do that? CodeFury I had same problem as you and

Android: <include> with RippleEffect & StateListAnimator

放肆的年华 提交于 2019-12-05 12:31:03
问题 I have a layout, that includes another layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/layout1"> <include layout="@layout/my_layout"/> </LinearLayout> I need to add a RippleEffect as well as a StateListAnimator to the included layout. Example: <include layout="@layout/my_layout" android:stateListAnimator="@anim/lift_up" android:background="

ripple drawable crashes the app on Android API 19

烈酒焚心 提交于 2019-12-05 05:38:01
I am using a custom ripple drawable <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_shortAnimTime" android:color="@android:color/white"> <item android:id="@android:id/mask"> <shape android:shape="rectangle" > <solid android:color="@android:color/white" /> </shape> </item> </ripple> but it crashes the app on API 19 android.content.res.Resources$NotFoundException: File res / drawable / ripple_effect_square2.xml from drawable resource ID #0x7f02017d at android.content.res.Resources

Ripples not showing with selectableItemBackground as foreground on a CardView with a Android 5.0 device

走远了吗. 提交于 2019-12-05 02:52:34
I'm running this on a Nexus 5. Here's part of the code for my CardView: CardView cardView = new CardView(getActivity()); cardView.setRadius(4); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400); lp.setMargins(32, 16, 32, 16); cardView.setLayoutParams(lp); cardView.setContentPadding(50, 50, 50, 50); ... cardView.setForeground(selectedItemDrawable); And here's how I get the selectedItemDrawable: int[] attrs = new int[] { R.attr.selectableItemBackground }; TypedArray ta = getActivity().obtainStyledAttributes(attrs); selectedItemDrawable = ta

android ripple button with background

给你一囗甜甜゛ 提交于 2019-12-04 07:00:31
I successfully created a ripple button in android 5.0 using XML. My code is as follows: <?xml version="1.0" encoding="utf-8"?> <!-- the flat button to be used in app --> <!-- define the ripple --> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <!-- the ripple object --> <item android:id="@android:id/mask"> <!-- button shape (w/ radius) --> <shape android:shape="rectangle"> <!-- radius of vertices --> <corners android:topLeftRadius="7dp" android:topRightRadius="7dp" android:bottomLeftRadius="7dp" android:bottomRightRadius="7dp"

Ripple effect on Spinner dropdown items colored background (appcompat-v7 V21)

倾然丶 夕夏残阳落幕 提交于 2019-12-04 04:58:08
I tried to apply ripple effect on Spinner dropdown items, like this: activity.java ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.array_name, R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); Spinner mSpinner = (Spinner) findViewById(R.id.spinner); mSpinner.setAdapter(adapter); simple_spinner_dropdown_item.xml <?xml version="1.0" encoding="utf-8"?> <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android

ImageView selectableItemBackgroundBorderless does not render outside of view bounds

喜你入骨 提交于 2019-12-04 03:33:45
I am using selectableItemBackgroundBorderless to add a ripple to an ImageView . My expected behaviour would be to have a circular ripple, extending the views size. Unfortunately the ripple gets cropped by the view bounds. How can this issue be solved? Default state: Pressed state: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/nav_instruction_container" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools" android:background="

Disable Ripple on ListView

荒凉一梦 提交于 2019-12-04 02:27:35
In Android 5.0, my ListView produces a ripple effect when clicking a list item. Is there a way to disable this effect? Looking at the docs, I don't see any way ( https://developer.android.com/reference/android/widget/ListView.html ) You can remove or replace the list selector using the android:listSelector property. The default list selector under Material is ?android:attr/selectableItemBackground which is a bounded ripple. <ListView ... android:listSelector="@drawable/my_list_selector" /> To completely disable selector, you can use a @null or @android:color/transparent (works better for some

Android: <include> with RippleEffect & StateListAnimator

自古美人都是妖i 提交于 2019-12-03 23:35:31
I have a layout, that includes another layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/layout1"> <include layout="@layout/my_layout"/> </LinearLayout> I need to add a RippleEffect as well as a StateListAnimator to the included layout. Example: <include layout="@layout/my_layout" android:stateListAnimator="@anim/lift_up" android:background="@drawable/ripple_effect"/> Both the RippleEffect and StateListAnimator work 100%. I cannot alter the

Ripple effect does not show up sometimes

拈花ヽ惹草 提交于 2019-12-03 05:16:54
I defined a ripple drawable and set it as the background for the listview item view's background. It almost works fine but the ripple effect just sometimes does not show up upon press. Here is the ripple drawable code: <?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_activated="true"> <shape><solid android:color="?android:attr/colorButtonNormal"/> </shape> </item> <item> <shape><solid android:color="@android:color/transparent"/> </shape> </item> <