我有一个大布局,里面有一个较小的布局。
如何在小布局周围创建线条边框?
原文由 user1302569 发布,翻译遵循 CC BY-SA 4.0 许可协议
我有一个大布局,里面有一个较小的布局。
如何在小布局周围创建线条边框?
原文由 user1302569 发布,翻译遵循 CC BY-SA 4.0 许可协议
似乎没有人使用我们提出的方法,所以我想我会分享,因为它涉及更简单的代码。只需使用填充将一个布局嵌套在另一个布局中,外部的布局可以着色,形成一个框架。
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/llSignatureBorder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@android:color/black"
android:orientation="vertical"
android:padding="4dp">
<com.yourmom.mobiledriverapp.Controls.SignatureArea
android:id="@+id/signatureArea"
android:layout_width="@dimen/signaturearea_width"
android:layout_height="@dimen/signaturearea_height"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp" />
</androidx.appcompat.widget.LinearLayoutCompat>
原文由 John Lord 发布,翻译遵循 CC BY-SA 4.0 许可协议
2 回答1.3k 阅读✓ 已解决
2 回答2.6k 阅读
2 回答1.7k 阅读
1 回答2.1k 阅读
1 回答1.1k 阅读
1 回答1.3k 阅读
1.3k 阅读
当然。您可以为所需的任何布局添加边框。基本上,您需要创建一个自定义可绘制对象并将其作为背景添加到您的布局中。例子:
在您的可绘制文件夹中创建一个名为
customborder.xml
的文件:现在将其作为背景应用到较小的布局中:
这应该够了吧。
另见: