[英]Element of listview out of bounds(visually) because of round edges
我正在 android 工作室中使用 Java 制作 android 应用程序。 我已经为带有圆形边缘的列表视图定义了可绘制背景。 但最后显示的行在视觉上超出了 listview 容器。 不仅仅是将它与下一条记录分开的线,而且“-”符号可以在容器的一半之外。 该应用程序看起来像这样
有没有办法将内容保持在界限内?
它正在发生 bcz 您的背景与列表视图不同,列表视图始终是方形布局。
所以基本上,使用cardview
并将app:cardCornerRadius=""
设置为 cardview 并在 cardview 内设置列表视图。
像这样。
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="YOUR_BACKGROUND"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
或者
另一种选择是使用圆角布局。 Git链接
并在任何 RoundCornerLayout 内设置列表视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.