ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – 卡片视图布局和分隔线颜色的突出

2019-06-07 12:09:36  阅读:190  来源: 互联网

标签:android android-layout android-xml android-recyclerview android-cardview


我在list_item.xml中使用了CardView布局“用于RecyclerView的xml post cell”,我试图使卡片突出,并且分隔符的颜色接近灰色,就像这样

但它似乎没有出现或颜色,
这个图像是针对当前的情况

这个post_item.xml

   <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_margin="5dp"
    android:elevation="6dp"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical"
            android:padding="10dp">

            <TextView
                android:id="@+id/postTitle"
                style="@style/Base.TextAppearance.AppCompat.Title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="5dp"
                android:layout_marginRight="5dp"
                android:ellipsize="end"
                android:maxLines="2"
                android:text="This is the post title,
you can check bla bla bla bla bla lkjdflkjhnfldkjhnflkjhnlfkjnglkjnlkjkln" />

            <TextView
                android:id="@+id/postDescription"
                style="@style/Base.TextAppearance.AppCompat.Body2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5dp"
                android:layout_marginEnd="5dp"
                android:layout_marginRight="5dp"
                android:ellipsize="end"
                android:maxLines="4"
                android:text="This is the post titldfkjfdjffkjdhfnkjdsfjnkdsjnksskskjfnksjfnksjfnksjfnkjdfbdnfbjvb jkxzbvkjxcvbvkjve,
you can check bla bla bla bla bla lkjdflkjhnfldkjhnflkjhnlfkjnglkjnlkjkln" />

        </LinearLayout>

        <ImageView
            android:id="@+id/postImage"
            android:layout_width="match_parent"
            android:layout_height="125dp"
            android:layout_marginEnd="5dp"
            android:layout_marginRight="5dp"
            android:layout_weight="3"
            android:adjustViewBounds="true"
            android:src="@mipmap/ic_launcher" />


    </LinearLayout>

</android.support.v7.widget.CardView>

我尝试通过在RecyclerView上添加这两行来解决这个问题,就像这个answer但它没有用到android:divider =“#E6E6E6”
 机器人:dividerHeight = “0像素”

解决方法:

在做了一些搜索之后,我发现了question关于同样的问题

The problem because this option was false in manifest file

<application android:hardwareAccelerated="true" ...>

answer还包含一些对我非常有帮助的选择

app:cardUseCompatPadding="true"

标签:android,android-layout,android-xml,android-recyclerview,android-cardview
来源: https://codeday.me/bug/20190607/1193661.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有