Android简易图片浏览器的实现

闲着没事,花了半个小时用这几天发布的部分内容来做一个Android简易图片浏览器小程序,代码设main_activity.xml设计首界面,设计三个按钮并赋予id,然后在MainActivity调用各个btn的id实现set方法,每个方法里实现intent跳转对应的界面即可!代码如下:(Main2-3-4Activity的代码我就不写了,在建立其MainActivity.java文件时,其xml对直接出来,并且我的MainActivity.java也没有写内容)

main_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:background="@drawable/bj"

    >

    <TextView

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="60dp"
        android:textSize="50dp"
        android:textColor="#FF9800"
        android:text="CSDN图片大全" />
<Button
    android:id="@+id/btn1"
    android:layout_marginTop="40dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="动漫"
    android:textSize="45sp"
    android:textColor="@color/colorAccent"

    />
    <Button
        android:id="@+id/btn2"
        android:layout_marginTop="40dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="游戏"
        android:textSize="45sp"
        android:textColor="@color/colorAccent"

        />
    <Button
        android:id="@+id/btn3"
        android:layout_marginTop="40dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="美女"
        android:textSize="45sp"
        android:textColor="@color/colorAccent"

        />

</LinearLayout>

activity_main2.xml

<?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:background="#7A3F51B5"
    android:orientation="vertical">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="欢迎来到动漫世界"
                android:gravity="center"
                android:textSize="40sp"
                />
            <ImageView
                android:background="@drawable/dm"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm1"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm2"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm3"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm4"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm5"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <ImageView
                android:background="@drawable/dm6"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                />
            <TextView
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="40sp"
                android:text="滑到最后一页了哦"
                />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

activity_main3.xml

<?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:background="#FF226F"
    android:orientation="vertical">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="欢迎来到游戏世界"
                android:gravity="center"
                android:textSize="40sp"
                />
            <ImageView
                android:background="@drawable/youxi"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi2"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi3"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi4"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi1"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi5"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi6"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi7"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <ImageView
                android:background="@drawable/youxi8"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                />
            <TextView
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="40sp"
                android:text="滑到最后一页了哦"
                />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

activity_main4.xml

<?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">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:background="#9A86AF4C"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="欢迎来到美女世界"

                android:gravity="center"
                android:textSize="40sp"
                />
            <ImageView

                android:background="@drawable/mn1"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn2"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn3"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn4"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn5"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn6"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn7"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn8"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn9"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />
            <ImageView
                android:background="@drawable/mn10"
                android:layout_width="match_parent"
                android:layout_height="550dp"
                />

            <TextView
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="40sp"
                android:text="滑到最后一页了哦"
                />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

MainActivity,java

package com.example.allphones;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
private Button btn1,btn2,btn3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn1=findViewById(R.id.btn1);
        btn2=findViewById(R.id.btn2);
        btn3=findViewById(R.id.btn3);
                btn1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent=new Intent(MainActivity.this,Main2Activity.class);
                        startActivity(intent);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(MainActivity.this,Main3Activity.class);
                startActivity(intent);
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(MainActivity.this,Main4Activity.class);
                startActivity(intent);

            }
        });
    }
}

到此这篇关于Android简易图片浏览器的实现的文章就介绍到这了,更多相关Android 图片浏览器内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Android实现图片浏览器示例

    本文所述为一个基础的Android图片浏览器代码,是仿写Google原版实现的,代码中实现了主要的实现过程和方法,具体的完善还需要自己添加,代码中有很多注释,可帮助新手们快速理解代码,使用了部分图像资源. 主要功能代码如下: package com.android.coding; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.Vi

  • Android使用gallery和imageSwitch制作可左右循环滑动的图片浏览器

    效果图: 为了使图片浏览器左右无限循环滑动 我们要自定义gallery的adapter 如果要想自定义adapter首先要了解这几个方法 @Override public int getCount() { // TODO Auto-generated method stub return 0; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @O

  • Android编程实现的超炫图片浏览器

    本文实例讲述了Android编程实现的超炫图片浏览器.分享给大家供大家参考,具体如下: 使用过Android自带的gallery组件的人都知道,gallery实现的效果就是拖动浏览一组图片,相比iphone里也是用于拖动浏览图片的coverflow,显然逊色不少.实际上,可以通过扩展gallery,通过伪3D变换可以基本实现coverflow的效果.本文通过源代码解析这一功能的实现.具体代码作用可参照注释. 最终实现效果如下: 要使用gallery,我们必须首先给其指定一个adapter.在这里

  • Android实现中轴旋转特效 Android制作别样的图片浏览器

    Android API Demos中有很多非常Nice的例子,这些例子的代码都写的很出色,如果大家把API Demos中的每个例子研究透了,那么恭喜你已经成为一个真正的Android高手了.这也算是给一些比较迷茫的Android开发者一个指出了一个提升自我能力的方向吧.API Demos中的例子众多,今天我们就来模仿其中一个3D变换的特效,来实现一种别样的图片浏览器. 既然是做中轴旋转的特效,那么肯定就要用到3D变换的功能.在Android中如果想要实现3D效果一般有两种选择,一是使用Open

  • Android实现网络图片浏览器

    本文实例为大家分享了Android网络图片浏览器的制作过程,供大家参考,具体内容如下 一.创建一个"网络图片浏览器的应用程序",并设计用户交互界面,"网络图片浏览器"对应的布局文件(activity_main.xml)代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.and

  • Android实现幻灯片式图片浏览器

    我们来实现一个幻灯片式图片浏览器: 最下面一个画廊视图,选中画廊中的图片,会在上面的ImageSwitcher控件中显示大图. 效果图如图 实现方法: 在布局文件中添加图片切换控件ImageSwitcher和画廊视图控件Gallery res/layout/main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas

  • Android自定义Gallery控件实现3D图片浏览器

    本篇文章主要介绍如何使用自定义的Gallery控件,实现3D效果的图片浏览器的效果. 话不多说,先看效果. 上面是一个自定义的Gallery控件,实现倒影和仿3D的效果,下面是一个图片查看器,点击上面的小图片,可以在下面查看大图片. 下面重点说一下,实现图片查看器的思路. 1.手机中图片路径的获取 首先,先不管图片如何展示,如果我们想实现图片查看器的功能,我们首先需要做的是获取到所有的图片的路径信息,只有这样,我们才能实现对图片的查看. 我们可以使用下面的代码实现 private List<St

  • Android简易图片浏览器的实现

    闲着没事,花了半个小时用这几天发布的部分内容来做一个Android简易图片浏览器小程序,代码设main_activity.xml设计首界面,设计三个按钮并赋予id,然后在MainActivity调用各个btn的id实现set方法,每个方法里实现intent跳转对应的界面即可!代码如下:(Main2-3-4Activity的代码我就不写了,在建立其MainActivity.java文件时,其xml对直接出来,并且我的MainActivity.java也没有写内容) main_activity.xm

  • C#编程实现简易图片浏览器的方法

    本文实例讲述了C#编程实现简易图片浏览器的方法.分享给大家供大家参考,具体如下: 首先需要加上命名空间 using system.io; 拖一个PICTUREBOX,两个TEXTBOX string fold = "";//用来存不包含文件后缀名的路径 string[] files;//用来存当前所有统一后缀文件的总路径 int pos=0;//用于图片切换 private void button1_Click(object sender, EventArgs e) { OpenFil

  • MPBrowser简易图片浏览器 v1.0

    MPBrowser.js 复制代码 代码如下: var thisImgNo = 290; function ajaxConn(){     var xmlhttp = false;     try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}     catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}     catch(e){try{xml

  • Android微信图片浏览框架设计

    一.业务场景 1.聊天界面发送图片==>多选点选+有右上角"发送"+图片预览==>图片预览支持右上角"发送"逻辑 2.发表动态==>多选点选+右上角"完成" + 图片预览==>图片预览支持右上角"完成"逻辑 3.个人资料更改头像==>单选点选 + 图片预览截图==>图片预览截图支持右上角"使用"逻辑 二.Intent参数设计; (Intent传参原则:尽量不要使用自定义类

随机推荐