【问题标题】:Creating a simple brochure app in android在 android 中创建一个简单的小册子应用程序
【发布时间】:2012-01-06 04:53:00
【问题描述】:

我想开发一个宣传册应用程序,任何人都可以在其中通过从一张照片轻弹(或滚动)到另一张照片来浏览各种照片。这是我遇到路障的地方。我需要知道我需要使用哪些方法(例如 OnClickListener)来实现。我还想添加额外的 UI 功能(例如,捏缩放、限制视图到横向)你能指导我看一些教程吗?如果你以前开发过这样的应用程序,你能告诉我你在工作时遇到了什么问题。

我在一个问题上问了很多。只需提示我什么是重要的以及如何处理我可能面临的问题。

感谢您的投入和时间:)

【问题讨论】:

  • thinksteep....你能告诉我什么方法执行从一个图像到另一个图像的轻弹动作吗?提供的示例很好,但我想要的是通过在屏幕上滑动手指来更改图像。有什么特别的方法吗?

标签: java android image-gallery


【解决方案1】:

首先你从下面的代码中实现画廊视图:

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

    <FrameLayout android:id="@+id/frameLayout2"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:background="#ffffff">
        <LinearLayout android:id="@+id/LinearLayout01"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:orientation="vertical" android:layout_marginBottom="60dip">
            <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/examplegallery" android:layout_height="wrap_content" android:layout_width="fill_parent"/>
            <FrameLayout android:id="@+id/fr" android:layout_width="fill_parent"
            android:layout_height="150dip">
            <ImageView android:id="@+id/ImageView01"
            android:layout_gravity="center_horizontal"
                android:layout_width="200dip" android:layout_height="200dip"/></FrameLayout>
        </LinearLayout>

    </FrameLayout>

</LinearLayout>


public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_greetings);
         imgView = (ImageView)findViewById(R.id.ImageView01);
         btn_capture = (Button)findViewById(R.id.btn_Grid_Capture);
         btn_preview = (Button)findViewById(R.id.btn_Grid_PreviewGreeting);
         imgView.setImageResource(Imgid[0]);
            bundle = getIntent().getExtras();
             gallery = (Gallery) findViewById(R.id.examplegallery);
             gallery.setAdapter(new AddImgAdp(this));

             gallery.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView parent, View v, int position, long id) {
                    imgView.setImageResource(Imgid[position]); 
                    img_position = position;
                }
            });


    }

然后通过这个链接捏和缩放: android pinch zoom

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 2013-02-08
    相关资源
    最近更新 更多