Reputation: 347
I have a clickable listview in android and the ripple effect was working when I selected an item, but I change my styles file to add this line for the ripple effect work in buttons
<style name="InflorTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
//other things
<item name="colorControlHighlight">@color/ripple_material_dark</item>
</style>
after I added this line, the ripple effect works in buttons, but doesn't work in listview.
Any suggestions to solve my problem?
Here is my stles file:
<resources>
<style name="InflorTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorAccent</item>
<item name="colorControlHighlight">@color/ripple_material_dark</item>
</style>
<style name="InflorTheme" parent="InflorTheme.Base">
</style>
<style name="InflorTheme.Splash" parent="android:Theme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
here is my styles v-21:
<resources>
<style name="InflorTheme" parent="InflorTheme.Base">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
Here is my listview:
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/listBoletins"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:dividerHeight="1dp"
android:textFilterEnabled="false"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
local:MvxBind="ItemsSource Boletins; ItemClick BoletimClickCommand"
local:MvxItemTemplate="@layout/boletinsitem" />
Upvotes: 2
Views: 1460
Reputation: 7106
As simple as
<ListView
...
android:drawSelectorOnTop="true"/>
will enable the ripple effect on the list view.
Upvotes: 0
Reputation: 803
Add this in your item that you are rendering in adapter.
android:foreground="?attr/selectableItemBackground"
android:clickable="true"
in your view
Upvotes: 3
Reputation: 400
Why You make such a simple thing so complex.You should use Listview or "appcompat listview" intead of MvxListView.and try to make change in your style for your requirements.
and if U have your own restriction to your custom listview ,then you should try like this.myview is your layout view
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
View myView = findViewById(R.id.myView);
int[] attrs = new int[]{R.attr.selectableItemBackground};
TypedArray typedArray = getActivity().obtainStyledAttributes(attrs);
int backgroundResource = typedArray.getResourceId(0, 0);
myView.setBackgroundResource(backgroundResource);
}
and add this line in your xml file
<android:background="?android:attr/selectableItemBackground">
Upvotes: 0