在我的项目中,我RecyclerView在我的列表中使用CardView.在我的列表中,我必须CardView根据设备动态设置角半径.
有没有办法动态设置cardview转角半径值?
谢谢.
我将cardview放在scrollview中,我们希望看到底部应该显示边框(见下图).但事实并非如此.问题是我无法滚动到底部以查看cardview的边框.
SO上的所有解决方案都是将layout_margins更改为paddings,但如果我们想要显示边框,则不是cardview的情况.我基本上尝试了一切.但仍然无法奏效.

图片1.滚动到底部无法看到边框
图2.我们可以看到顶部边框
以下是xml代码
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
...
</LinearLayout>
</CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想知道两个小部件“ android.support.v7.widget.CardView”(使用Android Studio IDE组件选项板添加)和“ com.google.android.material.card.MaterialCardView”(在Material上使用)之间的区别设计文档。
它们是两个包含相同小部件的库吗?我应该使用哪一个以及如何做出此决定?
我尝试阅读更多有关developers.android的文档,但是developer.android上的文档确实很大,有很多版本,但我仍然有些困惑,无法在所有这些版本及其历史之间找到很好的解释全部以及它如何到达那里。有人乐于为我提供有关此历史的见解吗?
材料设计文档的用法:
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.card.MaterialCardView>
Run Code Online (Sandbox Code Playgroud)
资料来源:https : //material.io/develop/android/components/material-card-view/
使用Android Studio时添加的CardView XML:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud) 我需要在两者之间增加空间CardView.
我试图使用它card_view:cardUseCompatPadding,它不起作用.有帮助吗?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/all_restaurant_card_view"
android:layout_width="wrap_content"
android:layout_height="120dp"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardPreventCornerOverlap="true"
card_view:cardUseCompatPadding="true">
Run Code Online (Sandbox Code Playgroud) 我想实现一个屏幕,其中我有一个包含RecyclerView的卡片视图.
CardView应该与回收者视图的内容高度相同,这意味着如果RecyclerView的项目很少,我应该看到卡片的底角和底部阴影但是如果RecyclerView有很多项目,那么Card视图应该是使用RecyclerView"滚动"以获得RecylerView底部的cardview底角和阴影.
当用户开始滚动时,顶角会随RecyclerView滚动而消失:

最后,当用户到达RecyclerView的底部时,会出现底角和CardView的阴影:

从现在开始,我设法通过将RecyclerView放在CardView和CardView里面的NestedScrollView中来实现一个有效的实现,但是这打破了这个动作......
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:clipChildren="false"
android:id="@+id/containerLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
tools:ignore="MissingPrefix">
<android.support.v4.widget.NestedScrollView
android:clipToPadding="false"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="85dp"
android:paddingRight="85dp"
android:paddingTop="16dp">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:cardBackgroundColor="?android:attr/windowBackground">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
您对如何实施此类设计有任何暗示或想法吗?我想CoordinatorLayout可以帮助我,但我找不到任何东西......
谢谢
我想像这张图片一样开发List
我曾经习惯使用RecylerView ItemDecorator进行重叠.但它没有阴影就重叠了.屏幕和装饰器代码如下
public class OverlapDecoration extends RecyclerView.ItemDecoration {
private final static int vertOverlap = -50;
@Override
public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(0, 0, 0, vertOverlap);
}
}
Run Code Online (Sandbox Code Playgroud)
card_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:tag="cards main container">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@color/color_white"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="@+id/textViewName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:text="Android Name"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个CardView对齐底部屏幕,尽管我希望在CardView顶部添加更多阴影.我试过了
android:shadowColor="#000"
android:shadowDx="0"
android:shadowDy="30"
android:shadowRadius="50"
Run Code Online (Sandbox Code Playgroud)
但是看到没有变化这是我的代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clipToPadding="false"
android:clipChildren="false"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--rest of the code-->
<LinearLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:shadowColor="#000"
android:shadowDx="0"
android:shadowDy="30"
android:shadowRadius="50"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
android:divider="@android:color/transparent"
android:dividerHeight="0.0px"
android:clipToPadding="false"
android:clipChildren="false"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="false">
<!--rest of the code-->
</android.support.v7.widget.CardView>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) Android cardview 在卡片周围显示不必要的边框。我尝试了不同的东西,但我无法删除它。当我为卡片提供自定义背景颜色时会发生这种情况。当我删除 cardBackgroundColor 并使用默认值时。那么不必要的边框是不可见的。
我必须使用阴影和透明颜色代码。
这是我的布局 CardView
<RelativeLayout
android:id="@+id/rlUserNamePassword"
android:layout_width="match_parent"
android:background="@android:color/transparent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
android:background="@android:color/transparent"
app:cardBackgroundColor="@color/form_card_bg_color"
app:cardElevation="@dimen/margin"
app:contentPadding="@dimen/margin_large"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/user" />
<android.support.design.widget.TextInputLayout
android:id="@+id/tilName"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.yaashvi.placeandpeople.customviews.CustomEditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:singleLine="true"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_large"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/password" />
<android.support.design.widget.TextInputLayout
android:id="@+id/tilPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.yaashvi.placeandpeople.customviews.CustomEditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:singleLine="true"
android:maxLines="1"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView >
<LinearLayout …Run Code Online (Sandbox Code Playgroud) 我搜索了很多,找到了一个直接而明确的解决方案,我认为这是一个受欢迎的问题,但不幸的是我找不到它.
我们希望有一个cardview列表,以便每张卡绑定到特定数据,每张卡片内部都有一个列表,显示有关其父级的元数据或详细数据.
所以我们在cardview中有一个嵌套列表.
通过简单的搜索,我们知道我们应该使用扩展列表视图,父项是cardview,我们必须为其子项设置另一个布局.
因此,当您点击卡片时,根卡上的卡片下方会显示一个项目列表.但是我们想在卡片里面显示孩子名单?
并且无法访问子列表id或任何其他内容来引用过渡动画和更改布局.
所以明确的问题是如何在cardview中添加listview?
我通过使用tablelayout和table行来关注我的工作.并且不希望使用外部库来实现稳定性和版本问题.这就是我的意思.
描述我的问题的图像

android ×10
cardview ×10
scrollview ×2
shadow ×2
box-shadow ×1
cornerradius ×1
listview ×1
nested ×1