You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Visual Studio 2017的Xamarin Android中设置按钮圆角及Drawable文件放置问题

解决Visual Studio 2017中Android项目Drawable文件的存放问题

别担心,我来帮你理清这个问题!在Visual Studio 2017的Android项目里,Drawable资源文件的存放位置是有固定路径的,具体步骤如下:

  • 首先打开你的Android项目,在解决方案资源管理器中找到Resources文件夹并展开它
  • 如果里面没有drawable文件夹,右键点击Resources → 选择「添加」→「新建文件夹」,将文件夹命名为drawable(注意全小写,Android对资源文件夹的命名有严格要求)
  • 最后把你的RoundShapeBtn.xml文件直接拖入这个新建的drawable文件夹就可以了

另外给你两个实用小提示:

  1. Android资源文件名推荐使用小写字母加下划线的规范(比如把RoundShapeBtn.xml改成round_shape_btn.xml),避免出现不必要的编译问题
  2. 你的圆角按钮Shape代码是完全可用的:
    • <solid>标签用来设置按钮的背景填充色
    • <corners>标签里的属性分别控制四个角的圆角半径,你这里设置了四个角都是10dp,刚好实现了全圆角的按钮效果

附你的Shape代码参考:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
<solid android:color="#6E6E6E"/>
<!-- this one is ths color of the Rounded Button -->
<corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
</shape>

内容的提问来源于stack exchange,提问作者Niteesh Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:56:19