问题描述
我正在试图创建具有角是上内侧向外侧和圆方布局的边界。我收集了,我需要创建两个形状组成一个xml绘制的定义:一个具有描边宽度和圆角半径,另一只用笔画宽度:
I’m attempting to create a layout border with corners that are square on the outside and round on the inside. I’ve gathered that I need to create an xml drawable definition composed of two shapes: one with a stroke width and corner radius and another with a stroke width only:
可绘制/
round_border.xml
round_border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="#FF000000" />
<padding android:left="7dp" android:top="7dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="4dp" />
<solid android:color="#FFC0C0C0" />
</shape>
square_border.xml
square_border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dp" android:color="#FF000000" />
<solid android:color="#FFC0C0C0" />
</shape>
每个这些作品independantly为界,当appliedby本身就像这样:
Each of these works independantly as a border when appliedby itself like so:
安卓背景=@可绘制/ round_border但是当他们一方或双方被添加到项目列表绘制如下所示:
android:background="@drawable/round_border" but when they either or both are added to an item-list drawable like so:
composite_border.xml
composite_border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<layer-list>
<item android:drawable="@drawable/round_border"/>
<!-- <item android:drawable="@drawable/square_border"/> -->
</layer-list>
</shape>
和
安卓背景=@可绘制/ composite_border
android:background="@drawable/composite_border"
布局的背景是全黑的,而不是只是一个黑色的边框 - 任何人都知道如何使图层列表的工作完成这个任务。
The layout's background is completely black instead of just a black border - anyone know how to make the layer list work for this task?
推荐答案
创建一个XML文件
像round_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#CCCC33"/>
<size
android:width="35dp"
android:height="35dp"/>
</shape>
在布局设置为背景
<LinearLayout
android:id="@+id/layout_wellbeing"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:background="@drawable/rounded_corner_leuvan"
android:orientation="horizontal" >
</LinearLayout>
这篇关于圆内边方形布局边境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!