【问题标题】:Image/ViewPager will not correctly use android:layout_gravity="bottom" and android:layout_alignParentBottom="true"Image/ViewPager 将无法正确使用 android:layout_gravity="bottom" 和 android:layout_alignParentBottom="true"
【发布时间】:2013-12-04 20:53:13
【问题描述】:

由于某种原因,我的 ViewPager(经典按钮)上的 android:layout_gravity="bottom" 和 android:layout_alignParentBottom="true" 似乎没有将图像放在屏幕底部,我不确定为什么。

非常感谢任何建议。

屏幕截图:

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" >

    <!-- The main content view -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="120dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtubeplayerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.idg.omv.ui.widget.VideosListView
        android:id="@+id/videosListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

  <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="70dip"
        android:layout_alignParentBottom="true" >

        <ScrollView
            android:id="@+id/groupScrollView"
            android:layout_width="fill_parent"
            android:layout_height="match_parent" >


        </ScrollView>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:src="@drawable/scroll_lt_arrow" />

        <Button
            android:id="@+id/fav_up_btn1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/fav_up_btn1" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/scroll_rt_arrow" />

        <android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_alignParentBottom="true" />
    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

【问题讨论】:

  • 您是否尝试过任何其他scaleType 值?看起来fitXY 在这里引起了您的问题。我想你要么在寻找 center 要么 centerCrop
  • 它已经居中了……为什么要把它移到布局的底部?
  • 我只需要将“经典”/ViewPager 移动到底部而不是屏幕中间
  • 啊,我明白了。我一直在尝试解决这个问题,我只是去阅读 Nav Drawer 文档;你不能这样做。检查我的答案。

标签: java android xml android-layout android-ui


【解决方案1】:

Navigation Drawer documentation 状态(强调我的):

要添加导航抽屉,请使用 DrawerLayout 对象声明您的用户界面作为布局的根视图。在DrawerLayout 中,添加一个包含屏幕主要内容的视图(抽屉隐藏时的主要布局)和另一个包含导航抽屉内容的视图。

您的 DrawerLayout xml 中不能有多个视图(除了您的抽屉和内容)。我建议将您的内容放在一个片段中,然后以类似于示例方式的代码对其进行扩充。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 2012-01-12
    相关资源
    最近更新 更多