Android的卡片视图在卡之间的细灰线 [英] Android card view has thin gray line in between cards
问题描述
我有一个机器人列表视图,显示卡般的美景,你可以在这个图片中看到,有我的卡片之间的细灰线:
我
如何才能摆脱灰色系的?
我的XML来实现此卡的看法是这样的:
<?XML版本=1.0编码=UTF-8&GT?;
<的FrameLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT><的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =6DP
机器人:layout_marginRight =6DP
机器人:layout_marginTop =4DP
机器人:layout_marginBottom =4DP
机器人:方向=垂直
机器人:背景=@绘制/ bg_card> <! - 卡的内容放在这里 - > <的TextView
机器人:ID =@ + ID / beerNameList
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=大文本
机器人:textAppearance =:/>中的Android ATTR / textAppearanceLarge? <的TextView
机器人:ID =@ + ID / beerBreweryNameList
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=TextView的/>< / LinearLayout中>< /&的FrameLayout GT;
bg_card.xml:
<?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<形状机器人:形状=矩形
机器人:抖动=真正的> <角落的android:半径=2DP/> [固体机器人:颜色=#CCC/> < /形状>
< /项目> <项目的android:底部=2DP>
<形状机器人:形状=矩形
机器人:抖动=真正的> <角落的android:半径=2DP/> [固体机器人:色=@机器人:彩色/白/> <填充机器人:底部=8DP
机器人:左=8DP
机器人:右=8DP
机器人:顶部=8DP/>
< /形状>
< /项目>
< /层列表>
试图在分隔高度的变化,这里是我的code它没有摆脱灰色系的:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直
工具:上下文=MainActivity。> <的LinearLayout
机器人:ID =@ + ID / linlaHeaderProgress
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:比重=中心
机器人:方向=垂直
机器人:知名度=水涨船高> <进度
机器人:ID =@ + ID / pbHeaderProgress
风格=的Android @风格/微调
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /进度>
< / LinearLayout中> < ListView控件
机器人:ID =@机器人:ID /列表
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:dividerHeight =0像素
>
< /&的ListView GT;< / LinearLayout中>
dividerHeight应该工作。作为一种变通方法,你可以分频器的颜色更改为背景色或透明色
< ListView控件
机器人:ID =@ + ID /安卓名单
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:分=#E6E6E6
机器人:dividerHeight =0像素/>
您也可以尝试这个技巧:
的android:分=@空
I have an android List view which shows card-like views, and as you can see in this picture, there is a thin gray line between my cards:
How can I get rid of the gray line?
My xml to achieve this card view is like this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
<TextView
android:id="@+id/beerNameList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/beerBreweryNameList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</FrameLayout>
bg_card.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp"/>
<solid android:color="#ccc" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp" />
<solid android:color="@android:color/white" />
<padding android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp" />
</shape>
</item>
</layer-list>
Tried the change in the divider height, here is my code it did not get rid of the gray line:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linlaHeaderProgress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<ProgressBar
android:id="@+id/pbHeaderProgress"
style="android@style/Spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ProgressBar>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="0px"
>
</ListView>
</LinearLayout>
dividerHeight should work. As a workaround you could change the colour of divider to your background color or to transparent colour
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#E6E6E6"
android:dividerHeight="0px"/>
You can also try to this trick:
android:divider="@null"
这篇关于Android的卡片视图在卡之间的细灰线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!