ViewPager
是否必须是活动布局中唯一存在的对象?我正在尝试实现这样的东西:
Does the ViewPager
have to be the only object present inside the activity layout?
I'm trying to implement something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reader_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/page_viewer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Gallery
android:id="@+id/miniatures_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content" /></LinearLayout>
我应该在哪里有一个在顶部滚动的大寻呼机(我有它)和一个较小的画廊在它下面滚动.这仅显示寻呼机而不显示图库.有什么建议吗?
Where should I have a big pager scrolling in the top (and I have it) and a smaller gallery scrolling under that. This shows me only the pager and not the gallery. Any suggestion?
ViewPager 不支持 wrap_content
因为它(通常)永远不会同时加载所有子项,因此不能获得适当的大小(选项是让寻呼机在每次切换页面时都会改变大小).
The ViewPager does not support wrap_content
as it (usually) never have all its children loaded at the same time, and can therefore not get an appropriate size (the option would be to have a pager that changes size every time you have switched page).
但是,您可以设置精确的尺寸(例如 150dp),match_parent
也可以.
您还可以通过更改 LayoutParams
中的 height
属性从代码中动态修改尺寸.
You can however set a precise dimension (e.g. 150dp) and match_parent
works as well.
You can also modify the dimensions dynamically from your code by changing the height
-attribute in its LayoutParams
.
这篇关于Android ViewPager 维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!