2011-04-21 4 views
7

각 화면 하단에 만든 버튼 막대를 넣으려고합니다. 나는 처음 화면을 꽤 쉽게 만들었습니다.버튼 막대가 화면 하단에 붙지 않습니다.

이제 다른 화면에 넣으려고했으나 화면 하단에 붙지 않는 것으로 보입니다. hiearchyviewer를 보면 RelativeLayout이 내 레이아웃과 단추 막대를 감싸는 것처럼 보이지만 전체 화면을 채우지는 못합니다. 높이가 부모를 채우도록 설정되어 있습니다.

어디에서 잘못 됐는지 지적하면 누구든지 도와 줄 수 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="fill_parent"> 
<RelativeLayout android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:orientation="vertical"> 
    <TableLayout android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:padding="5pt" android:id="@+id/table" 
     android:stretchColumns="1"> 
     <TableRow> 
      <TextView android:text="@string/Arbeiderbediende" 
       android:id="@+id/txtArbeiderBediende" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
     </TableRow> 

     <TableRow android:gravity="center"> 
      <RadioGroup android:layout_width="fill_parent" 
       android:layout_height="wrap_content" android:orientation="horizontal" 
       android:id="@+id/group1"> 

       <RadioButton style="@style/RadioButton" 
        android:layout_width="wrap_content" android:id="@+id/rbArbeider" 
        android:text="@string/Arbeider" android:layout_height="wrap_content" 
        android:paddingLeft="18pt" /> 

       <RadioButton style="@style/RadioButton" 
        android:layout_width="wrap_content" android:id="@+id/rbBediende" 
        android:text="@string/Bediende" android:layout_height="wrap_content" 
        android:layout_marginLeft="20pt" android:paddingLeft="18pt" /> 
      </RadioGroup> 
     </TableRow> 

     <TableRow android:gravity="center" android:paddingTop="5dip"> 
      <TextView android:text="@string/OverzichtFuncties" 
       android:id="@+id/txtFuncties" android:layout_width="0dip" 
       android:layout_weight="1" android:layout_height="wrap_content" /> 

      <Spinner android:layout_height="wrap_content" style="Spinner" 
       android:layout_width="0dip" android:layout_weight="2" 
       android:id="@+id/cmbFuncties" /> 
     </TableRow> 

     <TableRow android:gravity="center" android:paddingTop="5dip"> 
      <TextView android:text="@string/Regio" android:id="@+id/txtRegio" 
       android:layout_width="0dip" android:layout_weight="1" 
       android:layout_height="wrap_content" /> 

      <Spinner android:layout_height="wrap_content" 
       android:layout_width="0dip" android:layout_weight="2" android:id="@+id/cmbRegio" /> 
     </TableRow> 

     <TableRow android:gravity="center" android:paddingTop="5dip"> 
      <TextView android:text="@string/Opleiding" android:id="@+id/txtOpleidingsniveau" 
       android:layout_width="0dip" android:layout_weight="1" 
       android:layout_height="wrap_content" /> 

      <Spinner android:layout_height="wrap_content" 
       android:layout_width="0dip" android:layout_weight="2" 
       android:id="@+id/cmbOpleidingsniveau" /> 
     </TableRow> 

     <Button android:text="@string/VindJobButton" android:id="@+id/btnFindJob" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:layout_marginTop="10dip" /> 


    </TableLayout> 

    <stage.accent.Toolbar android:layout_width="fill_parent" 
     android:layout_height="70dip" android:layout_alignParentBottom="true" 
     android:layout_below="@+id/table" /> 
</RelativeLayout> 

이 내가 달성 한 결과는 그 결과 내가

enter image description hereenter image description here

답변

6

당신은 당신의 ButtonBar 컨트롤이 화면 하단에 항상 표시하고 RelativeLayoutScrollView 태그를 전환하고 RelativeLayout의 첫 번째 자식으로 당신의 ButtonBar 컨트롤을 이동, 당신은 할 수 있습니다 내용으로 스크롤되지하려면 의 ScrollView이 될 수있는 두 번째 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> 
    <stage.accent.Toolbar android:id="id/buttonBar" android:layout_width="fill_parent" 
     android:layout_height="70dip" android:layout_alignParentBottom="true" /> 
    <ScrollView android:layout_above="@+id/buttonBar" 
     android:layout_width="fill_parent" android:layout_height="fill_parent"> 
     <TableLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:padding="5pt" android:id="@+id/table" 
      android:stretchColumns="1"> 
      <TableRow> 
       <TextView android:text="@string/Arbeiderbediende" 
        android:id="@+id/txtArbeiderBediende" android:layout_width="wrap_content" 
        android:layout_height="wrap_content" /> 
      </TableRow> 
      <TableRow android:gravity="center"> 
       <RadioGroup android:layout_width="fill_parent" 
        android:layout_height="wrap_content" android:orientation="horizontal" 
        android:id="@+id/group1"> 

        <RadioButton style="@style/RadioButton" 
         android:layout_width="wrap_content" android:id="@+id/rbArbeider" 
         android:text="@string/Arbeider" android:layout_height="wrap_content" 
         android:paddingLeft="18pt" /> 

        <RadioButton style="@style/RadioButton" 
         android:layout_width="wrap_content" android:id="@+id/rbBediende" 
         android:text="@string/Bediende" android:layout_height="wrap_content" 
         android:layout_marginLeft="20pt" android:paddingLeft="18pt" /> 
       </RadioGroup> 
      </TableRow> 
      <TableRow android:gravity="center" android:paddingTop="5dip"> 
       <TextView android:text="@string/OverzichtFuncties" 
        android:id="@+id/txtFuncties" android:layout_width="0dip" 
        android:layout_weight="1" android:layout_height="wrap_content" /> 

       <Spinner android:layout_height="wrap_content" style="Spinner" 
        android:layout_width="0dip" android:layout_weight="2" 
        android:id="@+id/cmbFuncties" /> 
      </TableRow> 
      <TableRow android:gravity="center" android:paddingTop="5dip"> 
       <TextView android:text="@string/Regio" android:id="@+id/txtRegio" 
        android:layout_width="0dip" android:layout_weight="1" 
        android:layout_height="wrap_content" /> 

       <Spinner android:layout_height="wrap_content" 
        android:layout_width="0dip" android:layout_weight="2" android:id="@+id/cmbRegio" /> 
      </TableRow> 
      <TableRow android:gravity="center" android:paddingTop="5dip"> 
       <TextView android:text="@string/Opleiding" android:id="@+id/txtOpleidingsniveau" 
        android:layout_width="0dip" android:layout_weight="1" 
        android:layout_height="wrap_content" /> 

       <Spinner android:layout_height="wrap_content" 
        android:layout_width="0dip" android:layout_weight="2" 
        android:id="@+id/cmbOpleidingsniveau" /> 
      </TableRow> 
      <Button android:text="@string/VindJobButton" android:id="@+id/btnFindJob" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:layout_marginTop="10dip" /> 
     </TableLayout> 
    </ScrollView> 
</RelativeLayout> 

당신은 당신이 원하는 것을 달성 할 수 있습니다이 방법 :

portraitlandscape

버튼 막대는 항상 화면 하단에 있습니다. @Chirag I의 지시로

landscape 2

+0

내 질문이 있습니다. 이 화면보다 큽니다 .ScrollView를 구현 했으므로 스크롤하는 것이 문제가되지 않습니다. 그러나 화면의 마지막 부분 (예 : 제출 단추)이 막대 뒤에 숨겨집니다. 어떻게 해결할 수 있습니까? ? – Hannelore

+0

위의 예제는 단추 표시 줄을 항상 보이도록합니다 (내용과 함께 스크롤하지 않습니다). 또는 오해하고 제출 단추가 단추 표시 줄에 없습니까? – rekaszeru

+0

예, 단추 표시 줄을 고정시키고 싶습니다. 위에서 보았 듯이 버튼이 있는데, 예를 들어 콘텐츠 화면 맨 아래에 있습니다. 그러면 – Hannelore

0

하나를 수행하십시오 싶어 :

은 내가 사용하는 XML이다 메인 선형 레이아웃 스크롤 뷰 위 및끝나기스크롤보기는 아래쪽에 설정하십시오. bar.

내 suggetion이 될 수도 있습니다. LinearLayout이 기본보기입니다. 내에서

  • 또 다른있는 LinearLayout (layout_height = 0dp과에 layout_weight = 1) * ll_container *
  • 당신은 * ll_container * 장소

    을 TabBar의 tablelayout이있는 scrollview (layout_height = 0dp 및 layout_weight = 1)

  • 및 버튼

아마도 설명을 위해. layout_height가와에 layout_weight = 1 당신이 당신의 레이아웃을

UPD 당신의 버튼을 배치 한 후 다음 TabBar의 배치 및 후 나머지 전체 무료로 장소를 제공

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 
    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical"> 
     <ScrollView android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"> 
      <TableLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:padding="5pt" android:id="@+id/table" 
       android:stretchColumns="1"> 
       <TableRow> 
        <TextView android:text="@string/Arbeiderbediende" 
         android:id="@+id/txtArbeiderBediende" android:layout_width="wrap_content" 
         android:layout_height="wrap_content" /> 
       </TableRow> 

       <TableRow android:gravity="center"> 
        <RadioGroup android:layout_width="fill_parent" 
         android:layout_height="wrap_content" android:orientation="horizontal" 
         android:id="@+id/group1"> 

         <RadioButton style="@style/RadioButton" 
          android:layout_width="wrap_content" android:id="@+id/rbArbeider" 
          android:text="@string/Arbeider" android:layout_height="wrap_content" 
          android:paddingLeft="18pt" /> 

         <RadioButton style="@style/RadioButton" 
          android:layout_width="wrap_content" android:id="@+id/rbBediende" 
          android:text="@string/Bediende" android:layout_height="wrap_content" 
          android:layout_marginLeft="20pt" android:paddingLeft="18pt" /> 
        </RadioGroup> 
       </TableRow> 

       <TableRow android:gravity="center" android:paddingTop="5dip"> 
        <TextView android:text="@string/OverzichtFuncties" 
         android:id="@+id/txtFuncties" android:layout_width="0dip" 
         android:layout_weight="1" android:layout_height="wrap_content" /> 

        <Spinner android:layout_height="wrap_content" style="Spinner" 
         android:layout_width="0dip" android:layout_weight="2" 
         android:id="@+id/cmbFuncties" /> 
       </TableRow> 

       <TableRow android:gravity="center" android:paddingTop="5dip"> 
        <TextView android:text="@string/Regio" android:id="@+id/txtRegio" 
         android:layout_width="0dip" android:layout_weight="1" 
         android:layout_height="wrap_content" /> 

        <Spinner android:layout_height="wrap_content" 
         android:layout_width="0dip" android:layout_weight="2" android:id="@+id/cmbRegio" /> 
       </TableRow> 

       <TableRow android:gravity="center" android:paddingTop="5dip"> 
        <TextView android:text="@string/Opleiding" android:id="@+id/txtOpleidingsniveau" 
         android:layout_width="0dip" android:layout_weight="1" 
         android:layout_height="wrap_content" /> 

        <Spinner android:layout_height="wrap_content" 
         android:layout_width="0dip" android:layout_weight="2" 
         android:id="@+id/cmbOpleidingsniveau" /> 
       </TableRow> 
      </TableLayout> 
     </ScrollView> 
     <Button android:text="@string/VindJobButton" android:id="@+id/btnFindJob" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:layout_marginTop="10dip" /> 
    </LinearLayout> 
    <stage.accent.Toolbar android:layout_width="fill_parent" 
     android:layout_height="70dip" android:layout_alignParentBottom="true" 
     android:layout_below="@+id/table" /> 
</LinearLayout> 
+0

'

그리고 내용을 스크롤하여

, 당신은이 ButtonBar 컨트롤 뒤에 숨겨진되지 않습니다, 너무 그것의 마지막 비트를 볼 수 있습니다 상대 레이아웃과 가중치없이이를 처리했습니다. 어떤 차이가 있습니까? 나는 그것을 올바른 방법으로하고 싶습니다. – Hannelore

+0

두 가지 솔루션을 모두 사용할 수 있습니다. 그리고 나는 너의 질문을 다시 읽었다. 그리고 나는 당신이 buttonbar 만 항상 보여 져야한다고 생각했습니다. 그리고 난 정말 상대적인 레이아웃을 좋아하지 않아 ... 난 그냥 그들에게 너무 많은 문제가 있었어 – Tima

2

난 아직 여기있는 ScrollView를 사용하지 말아 0dp 제안 =와 함께입니다 아래쪽에 ButtonBar를 표시하는 방법

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="wrap_content"> 

    <RelativeLayout 
     android:id="@+id/headerlayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     > 

     <Button android:id="@+id/amap_back_btn" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" android:text="Back"> 
     </Button> 
     <TextView android:id="@+id/amap_txt" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:text="" android:layout_centerVertical="true" 
      android:layout_centerHorizontal="true"> 
     </TextView> 
     <ImageButton android:id="@+id/amap_action_btn" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:src="@drawable/icon_menu_action" 
      android:layout_alignParentTop="true" android:layout_alignParentRight="true"> 
     </ImageButton> 
    </RelativeLayout> 

    //What ever widgets you wants to add 

    <LinearLayout 
    android:id="@+id/bottomlayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:orientation="horizontal" 

    > 

     <ImageButton android:id="@+id/map_refresh_btn" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:src="@drawable/icon_refresh" 
      android:gravity="center" 
      > 
     </ImageButton> 
     <Button android:id="@+id/map_log_btn" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:text="Log" 
      android:gravity="center"> 
     </Button> 
     <Button android:id="@+id/map_map_btn" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:text="Map" 
      android:gravity="center" 
      > 
     </Button> 
    </LinearLayout> 

</RelativeLayout> 

이 모든 것이 가장 강력한 솔루션입니다.

유용하다고 생각되면 답변으로 표시하는 것을 잊지 마십시오.경우

+0

왜 ScrollViews를 사용하지 않습니까? 콘텐츠가 더 크면 (일부 화면에서는 안드로이드가 스크롤하지 않습니다.) – Hannelore

+0

댓글이나 스크롤보기 대신 ListView를 추가 할 수 있습니다. –

관련 문제