android-cardview

Programmatically set '?selectableItemBackground' on Android view

我与影子孤独终老i 提交于 2019-11-30 11:16:03
问题 In xml, I often do this to emulate onClick effect: <android.support.v7.widget.CardView android:id="@+id/cardView" android:layout_width="match_parent" android:layout_height="wrap_content" android:foreground="?selectableItemBackground"> ... </android.support.v7.widget.CardView> Is there any way to access ?selectableItemBackground in java? 回答1: For appcompat you can use, TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,

CardView elevation not working on Android 5.1.1

非 Y 不嫁゛ 提交于 2019-11-30 10:35:36
I am using CardView inside a RecyclerView. After reading a lot I ended up with following 'NOT WORKING' code only on Android 5.1.1. On Android Version prior to this one its working nice. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#11ffffff" android:orientation="vertical" android:paddingBottom="10dp"> <RelativeLayout android:layout_width="match_parent" android:layout_height=

CardView not showing shadow elevation

北城以北 提交于 2019-11-30 08:42:18
I am working with cardviews but the problem is my CardView is not showing any elevation or shadow. I have already tried some of the methods suggested in stackoverflow answers like I have tried using elevation and shadow property. I have also tried using card_view:cardUseCompatPadding="true", but without any success. This is my xml file <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content"

Cardview corner background not transparent

强颜欢笑 提交于 2019-11-30 07:06:55
I have a custom implementation of a CardView support widget but I can't seem to get the background for the corners transparent when I include it in my layout-file. However, if I simply place the CardView support widget in my layout-file it suddenly works. How can I get the corners transparent for my custom component? This is the layout file for my custom implementation of the CardView: view_card.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_card" android:layout_width="match_parent"

How to put a CardView attribute in a style?

痴心易碎 提交于 2019-11-30 06:49:28
问题 I have: in a file build.gradle (dependencies) dependencies { compile 'com.android.support:cardview-v7:21.0.+' } in a file styles.xml (styles definition) <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto"> <style name="CardViewStyle"> <item name="android:layout_margin">5dip</item> <item name="card_view:cardCornerRadius">4dp</item> <item name="card_view:cardElevation">4dp</item> </style> </resources> But compiler

Setting Elevation in XML on AppCompat CardView on Android 5.0

♀尐吖头ヾ 提交于 2019-11-30 06:13:24
问题 From what I understand, early in the preview stage there seemed to be no way to set elevation in XML only on CardView s without a hack in Java. Now that the official release is out, is there any way of doing this in XML without writing Java code to set elevation? I have tried card_view:cardElevation to no effect. I had thought when I was using the emulators for 5.0 everything was fine. But now that I'm using the official version on my actual device all of my CardView s disappeared Pre

Attach custom CardView style to theme

一曲冷凌霜 提交于 2019-11-30 06:11:56
In my app, I have two themes (light and dark), and I want all of my CardView s to change their background color depending on which theme is selected. What I don't want is: <android.support.v7.widget.CardView style="@style/CardView.MyBlue" android:layout_width="200dp" android:layout_height="100dp" android:layout_gravity="center_horizontal"> The above code is not dynamic. I need my two styles to automatically be applied depending on if a light or a dark theme is selected. What I have right now doesn't work: <style name="AppTheme.Light" parent="Theme.AppCompat.Light"> ... <item name=

Shared Element Transition on CardView with radius

隐身守侯 提交于 2019-11-30 03:59:55
I've been working on this problem for weeks and I'm still unable to solve this problem. So, I have a CardView that contains a LinearLayout with an ImageView. Without that radius Shared Element Transition works seamlessly. However, when I add radius (app:cardCornerRadius="25dp") to that CardView, the Shared Element Transition looks ugly because it remove the radius first and then start the animation . 1st Approach: ObjectAnimator I create ObjectAnimator to animate the radius value on card, and after the animation end it start the transition. ObjectAnimator animator = ObjectAnimator .ofFloat

android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow

只谈情不闲聊 提交于 2019-11-30 02:38:53
I tried to use CardView in my Application which worked pretty good within my xml Layout. Since I want to generate them in my code and not via xml I tried to set the radius with CardView.setRadius()-Method as suggested by Android Developers ( https://developer.android.com/preview/material/ui-widgets.html#cardview ). This does not work at all! I hope someone can help me, with my problem or got a nice workaround with xml layouts. This is my code: int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); float radius = (int) TypedValue

Android: how can I insert a RecyclerView inside CardView?

坚强是说给别人听的谎言 提交于 2019-11-30 02:01:08
The activity I am talking about must show a RecyclerView populated by CardViews as items. My goal is to show in every CardView a RecyclerView in its turn. Here my Activity's basic xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ConjActivity" > <android.support.v7.widget.RecyclerView android:id="@+id/conjCardList" android:layout_width="match_parent" android:layout_height="match_parent" android