刷图像的按钮,手指 [英] Swipe Image with button and fingers

查看:107
本文介绍了刷图像的按钮,手指的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个定制的画廊,在全屏模式下显示的图像,并能不同的图像,previous Next按钮和fingers.So之间刷卡,现在我做了部分不断变化的图像,手指,但我不得不重新设计我的xml文件和我的code中的整体结构和逻辑,我需要一些帮助或如何添加新stuff.So旧code,我是用刷卡的图像建议用手指是这样的:

I'm trying to do a custom gallery with images shown in fullscreen mode and be able to swipe between different images with Previous Next buttons and with fingers.So for now I did the part with changing images with fingers,but I had to redesign my xml file and the whole structure and logic of my code and I need a little help or suggestions of how to add the new stuff.So the old code which I was using to swipe images with fingers was like this :

  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        HorizontalPager realViewSwitcher = new HorizontalPager(getApplicationContext());

        ImageView img1 = new ImageView(getApplicationContext());
        ImageView img2 = new ImageView(getApplicationContext());
        ImageView img3 = new ImageView(getApplicationContext());
        ImageView img4 = new ImageView(getApplicationContext());
        ImageView img5 = new ImageView(getApplicationContext());
        ImageView img6 = new ImageView(getApplicationContext());

        img1.setImageResource(R.drawable.one);
        img2.setImageResource(R.drawable.two);
        img3.setImageResource(R.drawable.three);
        img4.setImageResource(R.drawable.four);
        img5.setImageResource(R.drawable.five);
        img6.setImageResource(R.drawable.six);

        realViewSwitcher.addView(img1);
        realViewSwitcher.addView(img2);
        realViewSwitcher.addView(img3);
        realViewSwitcher.addView(img4);
        realViewSwitcher.addView(img5);
        realViewSwitcher.addView(img6);

        setContentView(realViewSwitcher);

这code显示在全屏模式下的图像和我之间them.Now我需要做这样的事情刷卡:

And this code shows the image in fullscreen mode and I can swipe between them.Now I need to do something like this :

我希望能够用刷卡的按钮图像和finger.And我的第二个问题是我怎么能隐藏在顶部(返回,GALLER,资讯)酒吧和酒吧底部(previous,NEXT)和显示在全屏模式图像并仍然能够只用手指滑过图像。 下面是我的XML文件如下:

I want to be able to swipe images with buttons and finger.And my second question is how can I hide the bar in top (Back,Galler,Info) and the bar in bottom (Previous,Next) and show the image in Fullscreen mode and still be able to swipe images only with fingers. Here is how my xml file looks :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >

            <ImageView 
                android:id="@+id/single_card"
                android:src="@drawable/one"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <RelativeLayout
                android:id="@+id/actionbar"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#000000"
                android:orientation="horizontal"
                android:layout_gravity="center"
                android:padding="10dp"
                android:layout_alignParentTop="true" >

                <Button
                    android:id="@+id/back_button"
                    android:text="Back"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:background="#333333"
                    android:layout_centerVertical="true"
                    android:textSize="13dp"
                    android:textColor="#ffffff"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp" />

                <TextView 
                    android:text="Gallery"
                    android:textStyle="bold"
                    android:textSize="15dp"
                    android:textColor="#FFFFFF"
                    android:id="@+id/single_msg_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" 
                    android:layout_centerInParent="true"/>

                <Button
                    android:id="@+id/info_button"
                    android:text="Info"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:background="#333333"
                    android:layout_centerVertical="true"
                    android:textSize="13dp"
                    android:textColor="#ffffff"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp" />

            </RelativeLayout>


            <RelativeLayout 
                android:id="@+id/content"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_alignParentBottom="true"
                android:background="#000000" >


                <Button
                    android:id="@+id/previous_button"
                    android:text="Previous"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#333333"
                    android:layout_alignParentLeft="true"
                    android:textSize="13dp"
                    android:textColor="#ffffff"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp"
                    android:layout_marginLeft="50dp"
                    android:layout_marginBottom="10dp"
                    android:layout_alignParentBottom="true" />

                <Button
                    android:id="@+id/next_button"
                    android:text="Next"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="#333333"
                    android:layout_alignParentRight="true"
                    android:textSize="13dp"
                    android:textColor="#ffffff"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp"
                    android:layout_marginRight="50dp"
                    android:layout_marginBottom="10dp"
                    android:layout_alignParentBottom="true" />

            </RelativeLayout>


</RelativeLayout>

在此先感谢!任何帮助,建议或例如链接欢迎!

Thanks in advance!!! Any help,suggestions or links with example are welcomed!

推荐答案

使用视图流的项目做到这一点。您的code与添加imageViews并不是一个很好的解决方案都没有。

Use the view Flow project to do this. your code with adding imageViews is not a good solution at all.

viewFlow 在GitHub上。有与图像也例子。你要做的就是添加此布局中的活性,使图像适配器和多数民众赞成它。

see viewFlow on gitHub. there are examples with images also. all you do is add this layout in the activity, make an image adapter and thats it.

这篇关于刷图像的按钮,手指的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆