【发布时间】:2014-01-29 19:07:45
【问题描述】:
我的以下布局受接受的答案here的影响
list.xml
<?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:background="@drawable/bg"
android:orientation="vertical" >
....
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="@layout/footer" />
<ListView
android:id="@+id/song_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/footer"
android:layout_gravity="center_horizontal"
android:layoutAnimation="@anim/list_animation"
android:listSelector="@drawable/bg_list_row_song" />
</RelativeLayout>
</LinearLayout>
和footer.xml
<?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" >
<ImageView
android:id="@+id/img_ad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/adv" />
</LinearLayout>
生成这张图片
我的问题是我想要布局末尾的页脚和填充宽度,然后保持高度以使图像填充真实的移动屏幕宽度。我可以通过设置某个列表高度来做到这一点,但不希望它支持更长的屏幕。
有没有办法先计算页脚宽度并在其位于布局底部时保持其高度,然后将剩余高度分配给列表?以及如何?
编辑
感谢您的回答,我已经找到了最好的方法,我将图像缩放到比设备屏幕更宽,并且我使用了
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:adjustViewBounds="true"
android:src="@drawable/adv" />
<ListView
android:id="@+id/song_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/footer"
android:layoutAnimation="@anim/list_animation"
android:listSelector="@drawable/bg_list_row_song" />
</RelativeLayout>
【问题讨论】:
标签: android android-layout android-ui