これを実装するための簡単なものが欠けていると確信していますが、私が探しているものを機能させるために思いつくことができるすべての既知の組み合わせを実行しました。ListView アイテムがページを埋めないときに、ListView フッターを画面の下部に配置しようとしています。
たとえば、3 つの項目の ListView と FooterView (ListView の addFooterView を使用) を含むページがあり、その footerView を画面の下部に配置したいと考えています。ListView に画面をスクロールするのに十分な項目が含まれている場合、footerView は (画面の下部ではなく) リストの最後に配置する必要があります。
私が使用しようとしている XML を以下に示します。どんな助けでも大歓迎です!
レイアウト.xml
<?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:background="@+drawable/background">
<ListView
android:id="@+id/menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@android:color/transparent"
android:divider="@null">
</ListView></RelativeLayout>
ListViewRow.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
style="@style/Nationwide.menu">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_item"
style="@style/Nationwide.menu.row">
<ImageView
android:id="@+id/image_icon"
style="@style/Nationwide.menu.leftIcon" />
<TextView
android:id="@+id/nav_text"
style="@style/Nationwide.menu.text" />
<ImageView
android:id="@+id/chevron_symbol"
style="@style/Nationwide.menu.rightIcon" />
</LinearLayout>
<View
android:layout_height="1dp"
android:background="@drawable/nav_item_divider_dark" />
<View
android:layout_height="1dp"
android:background="@drawable/nav_item_divider_light" /></LinearLayout>
ListViewFooter.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<View
android:id="@+id/footer_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true" /></RelativeLayout>
ジャワ
LayoutInflater inflater = this.getLayoutInflater();
View footerView = inflater.inflate(R.layout.footer, null);
footerView.findViewById(R.id.footer_image).setBackgroundDrawable(resources.getDrawable(R.drawable.cone_footer));
mMenuListView.addFooterView(footerView);
これまでに試したことは次のとおりです。
- 上記のようにフッター ビューを追加する
- ListView の背景としてドローアブル リソースを追加します (これにより、ListView が画面の幅全体にまたがらず、9 パッチの伸縮可能な領域が原因で奇妙な方法でスクロールするようになりました)
- レイアウトの別のビューとして、cone_footer を追加する
前もって感謝します!