2016-11-22 11 views
0

私はlistviewと2つのボタンが並んでいるレイアウトをlistviewの一番下に持っています。私のリストビューのswiperefreshlayoutを追加するまで、すべてうまく動作します。ボタンを追加した後にswiperefreshlayout

私のコードは以下の通りです。私は君たちが私のコードを理解するための他の方法を把握することはできませんとしてここに私のコードをダンプする

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="#FFF" 
> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:id="@+id/search_bar" 
    android:background="@color/colorPrimaryDark" 
    android:orientation="vertical" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    > 

    <EditText 
     android:id="@+id/keyword_editText" 
     android:layout_width="fill_parent" 
     android:layout_height="30dp" 
     android:background="@drawable/search_edit_text" 
     android:hint="Keyword" 
     android:textColorHint="@color/list_item_title" 
     android:textColor="#000" 
     android:layout_centerVertical="true" 
     android:maxLines="1"/> 


</RelativeLayout> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/listView_layout" 
    android:orientation="vertical" 
    android:layout_below="@+id/search_bar" 

    > 

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/refresh" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent"> 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:id="@+id/RsListView" 
     android:dividerHeight="1dp" 
     android:divider="#D3D3D3"/> 

    </android.support.v4.widget.SwipeRefreshLayout> 

    <LinearLayout 
     android:id="@+id/test" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     > 
     <Button 
      android:id="@+id/req_history_button" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Request History" 
      android:layout_weight="1" 
      android:background="@drawable/request_history_button" 
      android:textColor="@drawable/button_text_color" 
      /> 
     <Button 
      android:id="@+id/apprv_history_button" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Approval History" 
      android:layout_weight="1" 
      android:background="@drawable/approval_history_button" 
      android:textColor="@drawable/button_text_color" 
      /> 
    </LinearLayout> 

</LinearLayout> 

申し訳ありません。

通常、すべての子どもたちが向きに応じても、寸法を有し

答えて

1

LinearLayout内部を助けてください。しかし、1人の子供が少しずつ食事をし、残りの人が残りを食べたい場合は、layout_weightというパラメータに興味があるかもしれません。スペースを埋める子供がandroid:layout_weight="1"になると、それは他のビューのための場所を作るスペースを埋めるでしょう。

ボタンを表示するには、android:layout_weight="1"SwipeRefreshLayoutを追加し、android:layout_height="0dp"と設定します。これであなたのボタンが見えるようになります。

+0

hi @R。 Zagórski私は私のswiperefreshlayoutに私のswiperefreshlayoutを追加する必要がありますなぜ私のボタンのlinearlayoutの前に私のswiperefreshlayoutを持っている?私のボタンが表示されるのは悪くないでしょうか? –

+1

現在、SwipeRefreshLayoutの高さはmatch_parentなので、LinearLayout全体を占めてボタンを隠すことになります。 layout_weight = 1をSwipeRefreshLayoutに追加すると、LinearLayoutに残っている空き領域を占有するはずです。したがって、ボタンが最初に配置され、wrap_contentの高さを持つため、必要なスペースがすべて確保され、残りのすべてのスペースはSwipeRefreshLayoutによって取得されます。 – rhari

+0

@rhariはweight = "1"、height = "match_parent"となっています。 –

関連する問題