2016-09-30 3 views
-3

이것은 Xamarin과 VS 2015 커뮤니티의 Android 프로젝트입니다. XML에서는 표준 선형 레이아웃이 있고 두 개의 버튼이있는 상대적 레이아웃이 있습니다.'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'라는 문자가 있습니다. 그 위에 마우스를 올리면 " 'http://schemas.android.com/apk/res/android:layout_bellow'속성이 선언되지 않습니다. 2. 화면의 중앙에있는 버튼을 배치하기 위해 상대 레이아웃을 사용하려고합니다. (1) 및 내가 할 수있는 방법 (2)?

+1

왜 RelativeLayout은 LinearLayout 안에 중첩되어 있습니까? 중첩 레이아웃은 퍼포먼스에 좋지 않습니다. –

+0

그게 내가 (레이아웃 초보자) 이해하는 방법입니다. 다른 해결책을 제안하십시오. 버튼을 한 줄에 넣고 화면 중앙에 배치하려면 어떻게해야합니까? –

+0

LinearLayout은 불필요하므로 제거하십시오. 중앙 버튼을 놓고 다른 두 버튼을 놓습니다. 하나는 왼쪽에 있고 다른 하나는 오른쪽에 있습니다. –

답변

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

나는 대답을 타이프하고 있었다. .. 우물! 나는 항상 두 번째 늦었습니다. 이 문제는 오타가되어 문제가되어 주제를 벗어났습니다. –

+0

맞춤법 검사에 대해 감사합니다. - 감사합니다. 그러나 문제는 여전히 지속됩니다. 'android : layout_below'문자열에는 여전히 밑줄이 표시되어 있으며 마우스를 올리면 경고/정보가 표시됩니다. –

+0

프로젝트 정리 – Nishith

-1

를 사용 불러야 android:layout_bellowandroid:layout_below에 철자 선형 레이아웃을 포함한 모든 작업과 두 개의 버튼을 사용하여 상대 레이아웃을 추가했습니다.

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

이제 모든 밑줄이 사라졌으며 화면에 가운데에 정렬 된 두 개의 나란히있는 버튼을 만들 수있었습니다. 제 목적은 어떻게 사물을 움직이는 지 조사하는 것이 었습니다. 이제 저는 통찰력을 얻었습니다.

0

@ Nick.P 원래 문제는 속성이 선언되지 않았기 때문입니다. 당신의 솔루션은 그것을 해결하지 못합니다. -1

관련 문제