RecyclerView 的透明背景 [英] Transparent Background For RecyclerView

查看:48
本文介绍了RecyclerView 的透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的回收站视图中聊天窗口的布局:

this is my layout for a chat window in within my recyclerview:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
android:background="@android:color/transparent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="10dp" />
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:orientation="vertical"
                android:layout_weight="418"
                android:layout_width="0dp"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:orientation="horizontal"
                        android:layout_height="wrap_content">
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="100"
                            android:gravity="right"
                            android:layout_height="match_parent">
                            <ImageButton
                                android:id="@+id/btn_profilepic_recview_chats"
                                android:background="@drawable/ripple"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content" />
                        </LinearLayout>
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="323"
                            android:layout_height="match_parent" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:orientation="horizontal"
                        android:layout_height="wrap_content">
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="100"
                            android:layout_height="wrap_content" />
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="323"
                            android:orientation="vertical"
                            android:layout_height="wrap_content">
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content">
                                <ImageView
                                    android:src="@drawable/chat_img_bubbletop"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content" />
                            </LinearLayout>
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:background="#afebff">
                                <TextView
                                    android:paddingLeft="8dp"
                                    android:paddingRight="8dp"
                                    android:textColor="#000000"
                                    android:textSize="17sp"
                                    android:id="@+id/txt_chatmessage_recview_chats"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content" />
                            </LinearLayout>
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content">
                                <ImageView
                                    android:src="@drawable/chat_img_bubbletop"
                                    android:rotation="180"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content" />
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:orientation="horizontal"
                        android:layout_height="wrap_content">
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="100"
                            android:layout_height="match_parent" />
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="323"
                            android:layout_height="match_parent">
                            <TextView
                                android:text="12.02.2012"
                                android:id="@+id/txt_date_recview_chats"
                                android:textSize="12sp"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content" />
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_weight="216"
                android:layout_width="0dp"
                android:layout_height="wrap_content" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="10dp" />
    </LinearLayout>
</android.support.v7.widget.CardView>

recyclerview 的背景是一个简单的图像,应该通过线性布局显示.但不幸的是,结果是这样的:

The Background of the recyclerview is a simple image, that is supposed to show through the linear layouts. But unfortunately, this is the result:

所以,如您所见,背景显示恰到好处,但我在这里使用的卡片视图的透明布局是一些有线黑色.

So, as you can see, the background is displayed just right but the supposed to be transparent layout for the cardview i am using here is some wired black.

我可以制作任何我想要的颜色,但是:

I can make it whatever color I want, but with:

android:background="@android:color/transparent"

它只是变黑了.

有人可以帮我吗?

谢谢!:)

推荐答案

... 原来 CARDVIEWS 没有这样的属性.使 rootlayout 成为线性布局解决了这个问题.

... turns out CARDVIEWS do not have such attribute. Making the rootlayout a linearlayout solved this issue.

这篇关于RecyclerView 的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆