请问 ViewPager
必须是活动布局中的唯一对象present?
我想实现这样的:
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).
不过,您可以设置precise尺寸(比如150dp)和 match_parent
工作为好。
您还可以动态改变高度
-attribute在其的LayoutParams
修改尺寸从code
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
.