Android: Turn pages up and down, and turn pages up and down
If you achieve up or down the page flip effect, we use this open source project: https://github.com/openaphid/android-flip
Aphid FlipView is a UI component that enables Flipboard paging.
After the download is complete, import it to your current project. Let's go down and flip the pages:
Paste the Code directly:
Layout file:
<span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" android:background="@android:color/white" > <ImageView android:id="@+id/tv_number" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" android:scaleType="fitXY" /></LinearLayout></span>
Main file:
<span style="font-size:14px;">public class MainActivity extends Activity {private int[] image=new int[]{R.drawable.qd,R.drawable.qg,R.drawable.qw};private Context activity=this;protected FlipViewController flipViewController;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);flipViewController=new FlipViewController(activity);flipViewController.setAdapter(new baseAdapter());setContentView(flipViewController);}public class baseAdapter extends BaseAdapter{@Overridepublic int getCount() {// TODO Auto-generated method stubreturn image.length;}@Overridepublic Object getItem(int position) {// TODO Auto-generated method stubreturn position;}@Overridepublic long getItemId(int position) {// TODO Auto-generated method stubreturn position;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {// TODO Auto-generated method stubif(convertView==null){convertView=new NumberTextVeiw(activity);}((ImageView)(convertView.findViewById(R.id.tv_number))).setBackgroundResource(image[position]);return convertView;}}private class NumberTextVeiw extends LinearLayout{ViewHolder viewHolder;public NumberTextVeiw(Context context) {super(context);inflate(context, R.layout.text_number_view, this);viewHolder=new ViewHolder();viewHolder.tv_number=(ImageView)findViewById(R.id.tv_number);}}private class ViewHolder {public ImageView tv_number;}}</span>
The above is the code to achieve the effect of turning pages up and down, if you want to achieve page turning between the left and right, you only need to change one code:
<span style="font-size:14px;">flipViewController=new FlipViewController(activity);</span>
Changed:
<span style="font-size:14px;">flipViewController=new FlipViewController(this, FlipViewController.HORIZONTAL);</span>
Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/42215085 sentiment control _