2011-03-02 10 views
0

기본적으로이 relativelayout에 textView, 회 전자 및 버튼을 추가하고 싶습니다. 보이는 같은 :Relativelayout의 버튼이 늘어났습니다

---- 텍스트 뷰 ----

----- 회 ----

------------ button--

문제는 오른쪽 하단의 버튼이 늘어나고 버튼 높이가 나머지 모든 부분을 의미한다는 것입니다.

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/surveyLayout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="20dp" 
    android:layout_marginTop="20dp" 
    android:layout_alignParentTop="true" 
    android:text="@string/selectSurvey" 
    android:textColor="@android:color/darker_gray" 
    android:id="@+id/hasSurveyLabel" 
    /> 
<Spinner 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/surveySpinner" 
    android:layout_below="@+id/hasSurveyLabel" 
    /> 
<Button 
    android:layout_width="wrap_content" 
    android:layout_height="30dp" 
    android:id="@+id/startButton" 
    android:text="@string/start" 
    **android:layout_below="@+id/surveySpinner"** 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:paddingTop="10dp" 
    android:paddingLeft="30dp" 
    android:paddingRight="30dp" 
    /> 

우리가 layout_below를 사용하는 경우, 스피너 아래 버튼, 그냥 아래에 있어야한다, 그것 때문에 layout_below입니다 같은데, 공백 당신은 그것을 정의하지 않는 한.
어떻게이 문제를 해결할 수 있습니까?
내가 기대하는 바는 회 전자 아래의 단추와 화면의 아래쪽에 단추를 넣는 것입니다.
나는 며칠 동안이 일에 어려움을 겪고있다. 감사.

+0

누구든지 여기에서 도움을받을 수 있습니까? – Usher

답변

2

회 전자에 대한 참조를 제거하고 오른쪽 하단에 배치합니다. 비슷한 화면 레이아웃이 있으며 다음 버튼 설정이 유용합니다.

<Button 
    android:id ="@+id/testButton" 
    android:text="Testing" 
    android:layout_width ="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight ="true" /> 

또는 아래쪽에 배치 된 LinearLayout을 감싸는 방법을 본 적이 있습니다. 그러나 레이어링은 불필요하게 보입니다. 희망이 도움이!

<LinearLayout 
     android:orientation ="horizontal" 
     android:layout_width ="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight ="true"> 

     <Button 
     android:id ="@+id/testButton" 
     android:text="Testing" 
     android:layout_width ="wrap_content" 
     android:layout_height="wrap_content" /> 

    </LinearLayout> 
+0

이전에 첫 번째 솔루션을 시도했지만 방향을 변경하면 단추가 잘립니다. – Usher

+0

두 번째 솔루션이 저에게 효과적입니다. 고마워! – Usher

0

신장 만 늘 렸습니까? 그렇다면 android:layout_alignParentBottom="true"을 제거하고 Spinner를 참조하고 오른쪽으로 정렬 시키십시오.

+0

버튼은 맨 아래에 있지 않습니다 .... – Usher

관련 문제