【发布时间】:2014-02-26 03:03:08
【问题描述】:
我有一个浏览器,它保存由 Nostra 的通用图像加载器加载的图像。这个 viewpager 也是作为标题的列表视图的一部分。将高度设置为 wrap_content 不起作用,它什么也没有显示,但如果我将它设置为特定的倾角,它就会起作用。我的怀疑是,viewpager 在加载图像之前会包装其内容,因此它不会显示任何内容。
这是布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp">
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@id/viewpager"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<com.sblive.other.CirclePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="3dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
ViewPager 的 PagerAdapter 的一部分:
@Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.header_item, container,false);
ImageView img = (ImageView) itemView.findViewById(R.id.imageView);
ProgressBar progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
display(img, list.get(position), progressBar);
((ViewPager) container).addView(itemView);
return itemView;
}
【问题讨论】:
标签: android android-layout android-viewpager