大家好我这里有viewpager宽度问题。这不占用全屏宽度。你能回答我吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/project_detail_layout"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
/>
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
/>
片段代码就是这样。我在这里动态添加图像。图像从 chache 或 sdcards 加载或在任一情况下下载。
public static class ArrayListFragment extends Fragment {
int mNum;
static ArrayListFragment newInstance(int num) {
ArrayListFragment f = new ArrayListFragment();
// Supply num input as an argument.
Bundle args = new Bundle();
args.putInt("num", num);
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNum = getArguments() != null ? getArguments().getInt("num") : 1;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ImageView image = new ImageView(getActivity());
//image.setImageBitmap(bitmap.get(mNum));
imageLoader.DisplayImage(bitmap.get(mNum), image);
LinearLayout layout = new LinearLayout(getActivity());
layout.setLayoutParams(new LayoutParams(android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, android.widget.RelativeLayout.LayoutParams.MATCH_PARENT));
layout.setGravity(Gravity.CENTER);
layout.addView(image);
return layout;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// setListAdapter(new ArrayAdapter<String>(getActivity(),
// android.R.layout.simple_list_item_1, Cheeses.sCheeseStrings));
}
}
你能告诉我我在哪里错误吗?