2017-12-21 5 views
0

属性をButtonに設定できません。私は何が間違っているのか分からないが、Visual Studioは属性が宣言されていないと言っている。 Android:BorderColorも機能しません。Xamarin.Android Button Borderが宣言されていません

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> 
+2

添付した画像ではなく、関連するコードをテキストとして編集してください。 – avojak

+0

申し訳ありません。ちょうど質問を更新しました:)ありがとう! –

答えて

0

私のボタンにBorderColor属性を設定することはできません。

あなたButtonの背景として形状の描画可能(長方形)を設定し、@Konstantin Burov's answerを参照することができます。

<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> 

効果:

enter image description here

を更新:

これは回避策はありませんが、それを答えは、はありません属性はAndroidです。次の点に注意してください:

ほとんどのAndroidビューはAndroid名前空間に属性を持っています。これらの属性を参照するときは、名前空間接頭辞を含める必要があります。そうでない場合、属性はaaptによってカスタム属性として解釈されます。

これが原因で機能しないため、このプロジェクトをエラーなくデバイスに展開できます。

+0

これは私のために働く。ありがとうございますが、回避策のように見えます。私は、ボタンの境界を設定する他の方法はないと想像することはできません。 –

+0

@ ls-dev、私は私の答えを更新しています、それを確認してください。 –

+0

ありがとうございます!それを知らなかった。 –

0
The 'BorderColor' attribute is not declared 

問題はインテリセンスがこれらの属性は、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 
+0

Hmmこのソリューションは、より良いもののように見えますが、私のためには機能しません。他の.xsdファイルがありますか? –

関連する問題