【问题标题】:ViewPager problemsViewPager 问题
【发布时间】:2021-11-30 11:50:03
【问题描述】:

我设置了 ViewPager 的高度 wrap_content 但它不起作用。我尝试了其他类似问题的答案,但没有解决我的问题。我的 activity_main 代码是这样的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#C49A1544"
    tools:context=".MainActivity">

    <include layout="@layout/toolbar"
        android:id="@+id/main_toolbar"/>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewpager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/standard_margin_x2"
        android:layout_below="@id/main_toolbar"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true" />

</RelativeLayout>

我有 3 个片段布局。真的很抱歉我的英语不好,我是Android应用程序开发的初学者,请帮助我。

【问题讨论】:

  • but it doesn't work 什么不起作用?
  • wrap_content 在视图寻呼机中不起作用
  • 我不明白你说它不起作用是什么意思,发生了什么?
  • 如果您查看图像,您会在页面下方看到空白,我想包装内容
  • 啊,我明白了,那为什么不使用 match_parent 呢?

标签: android android-viewpager android-wrap-content


【解决方案1】:

我自己找到了解决方案。如果我们使用 UltraViewPager 库而不是默认的,问题就解决了,但是这个库有 bug。无论如何,感谢您尝试在您的 cmets 方面帮助我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多