如何创建带有透明边框的圆形图像视图?
How to create circle imageview with a transparent border?
我想创建一个与图中所示相同的警告对话框,但我一直不知道如何创建带有透明边框的中心图像视图。
您的对话框有一些类似于 BottomAppBar
和 FloatingActionButton
的 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
样式的详细信息,请参阅 developer documentation
我想创建一个与图中所示相同的警告对话框,但我一直不知道如何创建带有透明边框的中心图像视图。
您的对话框有一些类似于 BottomAppBar
和 FloatingActionButton
的 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
样式的详细信息,请参阅 developer documentation