1
我需要为视图绘制边框..我按照以下方式绘制了边框。但是我还需要在左侧/右侧留出一些空白。可在Android中使用左侧或右侧边距绘制边框的边框
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
</shape>
</item>
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<stroke
android:width="2dp"
android:color="@color/border_color"/>
</shape>
</item>
</layer-list>
我已经尝试了一点插入,但不能有所需的结果。
我该怎么做?
如果这是视图的绘制,为什么不把保证金上的观点,而不是在绘制? – xiaomi
为什么不在布局文件中使用'android:layout_marginRight'和'android:layout_marginLeft'作为视图? –
我不能把保证金放在视图上。我必须有一个底部边界,以便有一定的余量。我必须在TextView(我的活动的标题)下放置一个底部边框,以便看起来好像不完整的文本具有底部边框。我可以通过使用视图并为其添加边距并将其放置在TextView下方。我可以将它的高度设置为1dp,这样做会。但它创造了一个额外的观点。我可以通过drawable来做到吗? – VinayChoudhary99