我对ViewPager
有疑问,每个页面都与屏幕底部对齐,当每View's
layout_height
= wrap_content
时,我也设置{{1}对于margin
,但每个CardView
都与CardView
和start
对齐,end
的填充也不起作用
CardView
代码:
ViewPagerAdapter
public class ViewPagerAdapter extends PagerAdapter {
...methods and variables...
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.page_training, null);
ViewPager wp = (ViewPager) container;
wp.addView(view, 0);
return view;
}
代码:
page_training.xml
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:padding="10dp"
android:layout_margin="20dp"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp">
... cardview content ...
</android.support.v7.widget.CardView>
地点:
PagerView