在 Android 中创建一个简单的小册子应用程序

发布于 2024-12-25 05:05:12 字数 250 浏览 1 评论 0原文

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

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

感谢您的投入和时间:)

I would like to develop a brochure app in which any person can go through various photos by flicking (or scrolling) them from one photo to the other. Here is where I hit a road block. I need to know what methods I need to use (eg OnClickListener) to implement. I would also like to add extra UI capabilities (eg pinch to zoom, restrict view to landscape) could you direct me to some tutorials. If you've worked on such an app before could you tell me what problems you faced while working.

I am asking a lot in one question. Just hint me through what is important and how to handle the problems I might face.

Thank you for your input and time :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹梦 2025-01-01 05:05:12

首先,通过以下代码实现图库视图:

<?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 捏合缩放

First you implement the Gallery View from the below code as:

<?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;
                }
            });


    }

Then Go through this link Pinching and Zooming:
android pinch zoom

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文