CardView 内的圆角图像
RoundCorner Image inside CardView
我使用支持库中的 CardView 我里面有一个圆角图像但是半径不适用于图像是 Cardview 的错误还是我的 XML 的问题? (我多次使用这个 RoundCorner 图像库并且工作正常)
我在 nexus 5 android L 和模拟器 nexus One android 4.1.1
上测试了这个
这是我的 XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res/com.rahavardnovin.Sada"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="@dimen/radius_medium"
card_view:cardElevation="@dimen/cardview_default_elevation"
card_view:cardUseCompatPadding="true">
<!-- date -->
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/global_padding"
android:layout_marginTop="3dp"
android:textSize="@dimen/textsize_smallest" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/global_padding"
android:layout_marginLeft="@dimen/global_padding"
android:layout_marginRight="@dimen/global_padding"
android:layout_marginTop="@dimen/actionbar_items_size"
android:gravity="right"
android:orientation="horizontal">
<com.makeramen.RoundedImageView
android:id="@+id/newsImage"
android:layout_width="@dimen/album_photo_width"
android:layout_height="@dimen/album_photo_height"
android:src="@drawable/avatar_agent"
app:riv_corner_radius="4dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/global_padding_small"
android:orientation="vertical"
android:paddingRight="10dp">
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:ellipsize="end"
android:textColor="@color/black_dark"
android:textSize="@dimen/textsize_large" />
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsContent"
style="@style/Textview.Gray40"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:ellipsize="end"
android:maxLines="4"
android:textSize="@dimen/abc_text_size_button_material" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
您用于 app:riv_corner_radius
的 xml 命名空间 是错误的。应该是
xmlns:app="http://schemas.android.com/apk/res-auto"
而不是
xmlns:app="http://schemas.android.com/tools"
我使用支持库中的 CardView 我里面有一个圆角图像但是半径不适用于图像是 Cardview 的错误还是我的 XML 的问题? (我多次使用这个 RoundCorner 图像库并且工作正常) 我在 nexus 5 android L 和模拟器 nexus One android 4.1.1
上测试了这个这是我的 XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res/com.rahavardnovin.Sada"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="@dimen/radius_medium"
card_view:cardElevation="@dimen/cardview_default_elevation"
card_view:cardUseCompatPadding="true">
<!-- date -->
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/global_padding"
android:layout_marginTop="3dp"
android:textSize="@dimen/textsize_smallest" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/global_padding"
android:layout_marginLeft="@dimen/global_padding"
android:layout_marginRight="@dimen/global_padding"
android:layout_marginTop="@dimen/actionbar_items_size"
android:gravity="right"
android:orientation="horizontal">
<com.makeramen.RoundedImageView
android:id="@+id/newsImage"
android:layout_width="@dimen/album_photo_width"
android:layout_height="@dimen/album_photo_height"
android:src="@drawable/avatar_agent"
app:riv_corner_radius="4dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="@dimen/global_padding_small"
android:orientation="vertical"
android:paddingRight="10dp">
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:ellipsize="end"
android:textColor="@color/black_dark"
android:textSize="@dimen/textsize_large" />
<com.rahavardnovin.Sada.ui.customui.PersianTextView
android:id="@+id/newsContent"
style="@style/Textview.Gray40"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:ellipsize="end"
android:maxLines="4"
android:textSize="@dimen/abc_text_size_button_material" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
您用于 app:riv_corner_radius
的 xml 命名空间 是错误的。应该是
xmlns:app="http://schemas.android.com/apk/res-auto"
而不是
xmlns:app="http://schemas.android.com/tools"