Dor*_*usu 48 android background shape
是否可以在xml中绘制一个形状,并使用png作为该形状的背景?我已经有了形状(它是一个带圆角的正方形),我想把背景放到那个正方形上.
小智 86
是的,您可以使用任何形状文件作为任何视图的背景.此示例创建圆形背景,白色和形状周围的黑色边框.
样品:
rounded_corner.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
<stroke
android:width="0.5dp"
android:color="@color/color_grey" />
<solid android:color="@color/color_white" />
</shape>
Run Code Online (Sandbox Code Playgroud)
你可以用这个,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/rounded_corner"
android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
54547 次 |
最近记录: |