我有一个 viewPager,我试图将它设置在屏幕底部(以及最后一个 RelativeLayout 中的所有其他项目)但是 android:layout_alignParentBottom="true" 和 android:gravity="bottom" 似乎对相对布局,我不确定为什么。
XML:
<?xml version="1.0" encoding="UTF-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:focusable="true"
android:orientation="vertical" >
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="220dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/darkgrey"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:textStyle="bold" />
<ListView
android:id="@+id/videosListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AAFFFFFF" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/footer"
android:gravity="bottom"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true" >
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageButton
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:focusable="false"
android:src="@drawable/scroll_lt_arrow" />
<ImageButton
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:focusable="false"
android:src="@drawable/scroll_rt_arrow" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
源代码段:
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = SAXParserAsyncTaskActivity.this;
ImageView imageView = new ImageView(context);
// imageView.setScaleType(ScaleType.FIT_XY);
imageView.setImageResource(mImages[position]);
((ViewPager) container).addView(imageView, 0);
return imageView;
}