【问题标题】:how to make background image with round corners in a layout of android?如何在android布局中制作带圆角的背景图像?
【发布时间】:2013-03-28 14:18:13
【问题描述】:

我正在尝试制作带有圆角的背景图像,以便在布局中进行设置。问题是如何在可绘制 XML 中为圆角设置图像,而不是使用纯色。

    <?xml version="1.0" encoding="utf-8"?>
     <shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle" android:padding="10dp">
      <!-- you can use any color you want I used here gray color-->
      <solid android:color="#ffffff"/> 
       <corners
     android:bottomRightRadius="10dp"
      android:bottomLeftRadius="10dp"
      android:topLeftRadius="10dp"
   android:topRightRadius="10dp"/>
   </shape>

【问题讨论】:

标签: android layout


【解决方案1】:

这对我有用:只需将文件名 round_corners.xml 添加到 drawable

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <gradient android:startColor="@color/lemon" android:endColor="@color/lemon_cream" android:angle="90" />
    <corners android:radius="30dp" />
</shape>

将此XML 添加到文件中并享受圆角。

【讨论】:

    猜你喜欢
    • 2020-05-11
    • 2019-12-07
    • 2019-11-14
    • 2013-04-16
    • 1970-01-01
    • 2012-04-07
    • 2012-06-16
    • 2016-03-18
    • 2013-09-20
    相关资源
    最近更新 更多