当前位置:首页 > 谈天说地

Android简易图片浏览器的实现

34资源网2022-03-31413

闲着没事,花了半个小时用这几天发布的部分内容来做一个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 图片浏览器内容请搜索萬仟网以前的文章或继续浏览下面的相关文章希望大家以后多多支持萬仟网!

看完文章,还可以扫描下面的二维码下载快手极速版领4元红包

快手极速版二维码

快手极速版新人见面礼

除了扫码领红包之外,大家还可以在快手极速版做签到,看视频,做任务,参与抽奖,邀请好友赚钱)。

邀请两个好友奖最高196元,如下图所示:

快手极速版邀请好友奖励

扫描二维码推送至手机访问。

版权声明:本文由34楼发布,如需转载请注明出处。

本文链接:https://www.34l.com/post/11469.html

分享给朋友:

相关文章

女人奋斗励志语录分享10句

女人奋斗励志语录分享10句

1、即便无人喝彩,也要守住自己的人生。每一次失败,都是成功的伏笔;每一次考验,都有一份收获;每一次泪水,都有一次醒悟;每一次磨难,都有生命的财富。每一次伤痛,都是成长的支柱。…

应用汇下载安装最新版(2021最新版应用汇app)

应用汇下载安装最新版(2021最新版应用汇app)

Donews8月17日消息(记者 邱慧)近日,为安卓手机服务的应用型软件“应用汇”新版正式上线,同时推出“应用收藏”功能——“应用集”。 应用集主要分为“推荐”、“最热”、“最新”三类。应用汇官方介绍,此次新版上线后,安装包被优化缩小,给…

购买须知模板怎么编辑(淘宝买家须知免费素材)

购买须知模板怎么编辑(淘宝买家须知免费素材)

为了帮助您入门,在您注册 Shopify 帐户时,后台的模版页面中会设置一个默认模版。如果您想为在线商店自定义一个不同的模版,则需要向后台添加一个模版。 您可通过以下几种方式添加模版: 如果您的计算机上的 .zip 文件中已有一个模版,那么…

视频号入口在哪里(视频号直播入口新手手册)

视频号入口在哪里(视频号直播入口新手手册)

视频号助手在哪里?视频号助手什么时候上线?微信视频号助手正式上线目前微信视频号助手已经开始内测使用了,大家可以直接在PC端扫码登录,管理自己的视频号,可以看到自己的各项动态数据,非常方便管理。 视频号助手在哪里 视频号助手在哪里? 手机微…

这4类项目,投资人打死都不想投

这4类项目,投资人打死都不想投

很多创业者常感慨:明明自己的项目很好,但聊了很多投资人,却没人愿意投,这是为什么呢? 我们知道融资成功的关键,在于要让投资人看到项目的价值。这个价值,不仅仅是你的项目好就行,除了项目本身,投资人还有很多关注点,如果这些地方不“达标”,投资人…

飞行汽车是一种应用层创新

飞行汽车是一种应用层创新

编者按:本文来自A轮财经,创业邦经授权发布。 作者|WX 今天在全球范围内,飞行汽车得到了越来越多的关注。 据摩根士丹利研报预计,2030年飞行汽车行业将形成3000亿美元的市场规模。2040年,该行业规模可能将达到1.5万亿美元。 作为新…