我在回收站视图中使用卡片,并希望突出显示其中一些卡片。
我首先想到的是带有不同颜色的阴影或边框,但是到目前为止,我找不到能够对其进行调整的任何属性
这是我的卡片视图:
My C# code:
var url = "mongodb://user:pass@servername:27017/admin?ssl=true";
var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(url));
var bytes = Convert.FromBase64String("MIID5TCCAs2gAwIBAgIJANoGBQADggEBAHaIdU9ri.....");
var cert = new X509Certificate2(bytes);
clientSettings.SslSettings = new SslSettings
{
ClientCertificates = new[] { cert },
CheckCertificateRevocation = false
};
clientSettings.UseSsl = true;
clientSettings.VerifySslCertificate = false;
var client = new MongoClient(clientSettings);
database = client.GetDatabase("databasename");
这就是我想要成为的样子:
最佳方案是将默认阴影颜色切换为更亮的颜色,但是如果这不可能,则可以使用内部边框
我该怎么做?
答案 0 :(得分:0)
这有点丑陋,但您可以在模型上添加另一个字段,将其用作在cardview上设置不同背景的基础。然后在适配器上,根据其状态以编程方式更改cardview的背景。如有必要,您需要经常notifyDatasetChanged。
答案 1 :(得分:0)
尝试这个库,很棒
安装
dependencies {
implementation 'com.loopeer.lib:shadow:0.0.4-beta3'
}
用法
<com.loopeer.shadow.ShadowView
android:id="@+id/shadow_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:elevation="10dp"
android:foreground="?attr/selectableItemBackground"
android:onClick="onShadowClickTest"
android:padding="10dp"
app:cornerRadius="4dp"
app:shadowMargin="20dp"
app:shadowRadius="14dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="YOUR_TEXT"/>
</com.loopeer.shadow.ShadowView>
属性
android:foreground
shadowMargin
shadowMarginTop
shadowMarginLeft
shadowMarginRight
shadowMarginBottom
cornerRadius
cornerRadiusTL
cornerRadiusTR
cornerRadiusBL
cornerRadiusBR
foregroundColor
shadowColor
shadowDx
shadowDy
shadowRadius
backgroundColor
希望它会为您提供帮助
答案 2 :(得分:0)
对于内部边框,您可以像这样创建xml
drawable
文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<stroke android:color="@color/colorAccent" android:width="8dp" />
</shape>
然后将其作为background
的第一个孩子中的CardView
。
将cardCorner radius
和xml
background
corner radius
设置为相同。