我无法将BorderColor
属性设置为Button
。我不确定我做错了什么,但Visual Studio说该属性未被声明。 Android:BorderColor
也不起作用。
The 'BorderColor' attribute is not declared
我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:id="@+id/header"
android:text="@string/header"
style="@style/header_text" />
<Button
android:id="@+id/phones_button"
android:layout_below="@id/header"
android:layout_alignParentStart="true"
android:layout_height="100dp"
android:layout_width="150dp"
android:textColor="@color/gray"
android:background="@color/white"
BorderColor="@color/gray"
android:text="@string/phones"
style="@style/button_style" />
</RelativeLayout>
答案 0 :(得分:0)
The 'BorderColor' attribute is not declared
问题是intellisense无法获取我们输入的属性,尽管这些属性存在于Android SDK中并显示未声明相应的属性。
这些是由于Visual Studio中的XML架构文件夹中缺少某些 .xsd 文件而发生的。
要解决此问题,请下载以下文件链接:
您可以手动下载并移动这些文件到:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\XML\Schemas
或
C:\Program Files (x86)\Microsoft Visual Studio 14.0\XML\Schemas\1033
答案 1 :(得分:0)
我无法将BorderColor属性设置为我的按钮。
您可以参考@Konstantin Burov's answer,将形状可绘制(矩形)设置为Button
的背景。
<Button
android:id="@+id/my_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textColor="@color/grey"
android:layout_margin="30dp"
android:background="@drawable/Button_Border"
/>
创建一个可绘制的矩形Button_Border.xml
并放入Resource/Drawable
文件夹:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/white" />
<stroke android:width="1dp" android:color="#FF4081"/>
</shape>
效果:
这不是一种解决方法,它是一个答案,BorderColor
中没有Android
属性。请注意:
大多数Android视图在Android命名空间中都有属性。引用这些属性时,必须包含命名空间前缀,否则您的属性将被aapt解释为自定义属性。
这就是为什么它不起作用,这就是你可以将这个项目部署到你的设备而没有错误的原因。