繁体   English   中英

如何创建带有透明边框的圆形图像视图?

[英]How to create circle imageview with a transparent border?

我想创建一个与图像中所示相同的警报对话框,但我坚持如何创建带有透明边框的中心图像视图。

在此处输入图片说明

您的对话框有一些类似于BottomAppBarFloatingActionButton View 当然,可以编写一个看起来就像一个BottomAppBar的自定义View ,但是使用原始的东西更容易。

您可以为对话框使用以下布局(我省略了按钮栏,因为我认为您已经知道您可以使用例如LinearLayout来实现这一点):

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bar"
    android:layout_width="match_parent"
    android:layout_height="96dp"
    android:layout_gravity="bottom"
    app:backgroundTint="#0000ff"
    app:fabAlignmentMode="center"
    app:fabCradleMargin="4dp"
    app:fabCradleRoundedCornerRadius="0dp"
    app:fabCradleVerticalOffset="4dp"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="#ffffff"
    android:textSize="12sp"
    android:text="@string/lorem_string"
    android:lines="3"
    android:ellipsize="end"
    android:padding="16dp"
    android:layout_gravity="bottom"
    />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_anchor="@id/bar"
    app:elevation="0dp"/>

对话框截图

有关设置BottomAppBar样式的更多信息,请参阅 开发人员文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM