2011-01-14 7 views
2

リストビューとリストビューの下のボタンを含むカスタムダイアログを作成したいとします。ボタンはリストビューの下にありますが、常に表示されている必要があります(layout_alignParentBottom = "true")。リストビューとボタンが常にフルスクリーンのカスタムダイアログ

私は非常にうまく動作するxmlを作成しましたが、長いリストでのみ使用できます。リストが短い場合、ボタンは画面の下にあり、ダイアログのタイトルの高さはダイアログの塗りつぶし画面に表示されます。添付の画像は私が今日入手したものを示しています。

要するに、私はnececcaryの場合にのみ画面を塗りつぶす通常のダイアログが必要です。

何らかの理由でxmlを投稿できません。私は、relativelayoutを使用して、ボタンは親パネルの下に配置され、小さなパネルはボタンの上に配置され、listviewはこのパネルの上に配置されます。 すべてのレイアウトはlayout:height = wrap_contentです。

ありがとうございました。 /マグナス

alt text

答えて

3

問題が解決されます。

私はalert_dialog.xmlをアンドロイドのソースコードから取り出して少し修正しました。私はリストビューをcustomPanel framelayoutに追加し、topPanelとcontentPanelを削除しました。

結果:コンテンツより大きくなく、画面の最大サイズのダイアログで、常にボタンが表示されます。 @Fresh_Meat

への答えで

1

あなたは、このようにリストビューの下部にボタンを追加することができます:あなたのアラートビュー内 http://www.anddev.org/code-snippets-for-android-f33/listview-with-a-footer-item-t49281.html

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="10dip" 
    > 
    <LinearLayout 
     android:id="@+id/bottom_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 
      <!--Put whatever view item you want here --> 
      <EditText 
      android:id="@+id/conversation_reply" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="write a reply..." 
      /> 
    </LinearLayout> 
    <ListView 
    android:id="@+id/android:list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:cacheColorHint="#00000000" 
    android:layout_above="@id/bottom_view" 
    /> 
</RelativeLayout> 

List with footer

使用この

5

This answerは一般的には正しいですが、人のためにかなりのオーバーヘッドが発生しますyネストされたレイアウト。結果は同じである

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    /> 
<!-- Notice layout_weight=1 and height=0dp - it's the most important thing here--> 


<WhateverLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
<!-- And the layout below the listview has some arbitrary height (but no weight!)--> 

</WhateverLayout> 

</LinearLayout> 

:「画面と大などのコンテンツとmaxよりも大きいんダイアログ必要なもの

は、特定の構成を持つ単純なLinearLayoutです、常にボタンが表示されます。

関連する問題