2016-09-30 18 views
-3

これはVS 2015 Community with XamarinのAndroidプロジェクトです。 XMLでは標準の線形レイアウトがあり、その内部には2つのボタンを持つ相対レイアウトがあります。'layout_bellow'属性が宣言されていません

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:minWidth="25px" 
    android:minHeight="25px"> 
    <RelativeLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1"> 
     <Button 
      android:text="Button 1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button1" /> 
     <Button 
      android:text="Button 2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button2" 
      android:layout_bellow="@id/button1" 
      /> 
    </RelativeLayout> 
</LinearLayout> 

1:エディタに緑色の下線が付いています。「android:layout_bellow」です。 2.相対レイアウトを使用して、画面中央のボタンを配置しようとしています。 (1)、および私が行うことができますどのように(2)?

+1

なぜあなたのRelativeLayoutはLinearLayoutの中にネストされていますか?レイアウトの入れ子は、パフォーマンスには悪いです。 –

+0

それは私(レイアウトの初心者)がそれを理解する方法です。他の解決策を提案してください。どのようにボタンを1つの行に配置し、画面の中央に配置できますか? –

+0

LinearLayoutは不要なので削除してください。センターボタンと他の2つのボタンを配置します。 1つはその左側に、もう1つは右側にあります。 –

答えて

2

変更の代わりに、この質問に貢献ありがとうございました。結局、私は取り除かデザインビューを使用して、以下のコード

  <Button 
       android:text="Button 1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button1" 
       android:layout_above="@id/button2" /> 
      <Button 
       android:text="Button 2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/button2" 

       /> 
+0

私は答えを入力していた...うわ!私はいつも2番目の遅れです。この問題はオススメの問題のために話題としてフラグを立ててください –

+0

あなたはスペルについて正しいです - ありがとう。しかし、問題は依然として続く。 'android:layout_below'文字列には下線が引かれていて、その上にマウスを置くと警告/情報が表示されます。 –

+0

プロジェクトをクリーンアップ – Nishith

-1

を使用.OR android:layout_bellowandroid:layout_belowにスペルリニアレイアウトを含むすべてのものを、2つのボタンを使って相対レイアウトを追加しました。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android" 
    p1:layout_width="match_parent" 
    p1:layout_height="match_parent" 
    p1:id="@+id/relativeLayout1"> 
    <Button 
     p1:text="Button 1" 
     p1:layout_centerVertical="true" 
     p1:layout_centerHorizontal="true" 
     p1:layout_width="wrap_content" 
     p1:layout_height="wrap_content" 
     p1:id="@+id/button1" /> 
    <Button 
     p1:text="Button 2" 
     p1:layout_centerVertical="true" 
     p1:layout_centerHorizontal="true" 
     p1:layout_toRightOf="@id/button1" 
     p1:layout_width="wrap_content" 
     p1:layout_height="wrap_content" 
     p1:id="@+id/button2" /> 
</RelativeLayout> 

すべての下線がなくなり、画面上に中央に並んだ2つのサイドバイサイドボタンを作成することができました。私の目的は、物事をどうやって行くのかを調べることでした。そして今私は洞察力を持っています。

0

@ Nick.P元の問題は、属性が宣言されていないということでした。あなたの解決策はそれを修正するものではなく、回避策です。 -1

関連する問題