Java android:layout“alignParentBottom=”;“真的”;android:gravity=";底部“;似乎对相对年轻没有影响
我尝试在屏幕底部设置一个viewPager(以及上一个RelativeLayout中的所有其他项目),但是android:layout\u alignParentBottom=“true”和android:gravity=“bottom”似乎对RelativeLayout没有影响,我不知道为什么 XML: 截图:Java android:layout“alignParentBottom=”;“真的”;android:gravity=";底部“;似乎对相对年轻没有影响,java,android,android-viewpager,android-relativelayout,layout-gravity,Java,Android,Android Viewpager,Android Relativelayout,Layout Gravity,我尝试在屏幕底部设置一个viewPager(以及上一个RelativeLayout中的所有其他项目),但是android:layout\u alignParentBottom=“true”和android:gravity=“bottom”似乎对RelativeLayout没有影响,我不知道为什么 XML: 截图: 尝试在页脚上使用android:layout\u alignParentBottom的问题在于页脚布局没有父项 layout\u alignParentBottom和RelativeL
尝试在
页脚上使用android:layout\u alignParentBottom
的问题在于页脚布局没有父项
layout\u alignParentBottom
和RelativeLayout提供的其他相关属性用于定位RelativeLayout的子视图。除非RelativeLayout嵌套在RelativeLayout中,否则它们不能用于将RelativeLayout定位在其父对象的内部
android:gravity
无法满足您的需要,因为它用于在视图中定位视图的子视图。如果要将视图设置为与其父视图的底部对齐,则应使用android:layout\u gravity
。有关更多信息,请参阅
您可能还需要阅读文档,因为我不认为它完全符合您的期望。如果您只有一个抽屉,您的DrawerLayout
应该只包含两个子项-抽屉和主要内容(其中任何一个都可以有子视图,但只需要有两个直接子项)。它们被放置在何处?屏幕截图对这里很有帮助。屏幕中间(谢谢!我先发了一张屏幕截图!)有什么想法吗?
<?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;
}