Android简易图片浏览器的实现

 更新时间:2022年03月31日 09:16:02   作者:DY.memory  
最近做了一个图片浏览小程序,本文主要介绍了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 图片浏览器内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Android实现关机与重启的几种方式(推荐)

    Android实现关机与重启的几种方式(推荐)

    这篇文章主要介绍了Android实现关机与重启的几种方式(推荐)的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2016-07-07
  • 教你一文搞懂Kotlin中的Jvm注解

    教你一文搞懂Kotlin中的Jvm注解

    这篇文章主要介绍了教你一文搞懂Kotlin中的Jvm注解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-10-10
  • 详解Android用Shape制作单边框图的两种思路和坑

    详解Android用Shape制作单边框图的两种思路和坑

    这篇文章主要介绍了详解Android用Shape制作单边框图的两种思路和坑,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-08-08
  • Android实现水波纹扩散效果的实例代码

    Android实现水波纹扩散效果的实例代码

    这篇文章主要介绍了Android实现水波纹扩散效果的实例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-05-05
  • 浅谈Android invalidate 分析

    浅谈Android invalidate 分析

    本篇文章主要介绍了浅谈Android invalidate 分析,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-04-04
  • 接口对象的实例化在接口回调中的使用方法

    接口对象的实例化在接口回调中的使用方法

    下面小编就为大家带来一篇接口对象的实例化在接口回调中的使用方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-02-02
  • Android 如何采用Lame编码器编码mp3文件

    Android 如何采用Lame编码器编码mp3文件

    这篇文章主要介绍了Android 如何采用Lame编码器编码mp3文件,帮助大家更好的理解和学习使用Android,感兴趣的朋友可以了解下
    2021-03-03
  • Android调节屏幕亮度实现代码

    Android调节屏幕亮度实现代码

    这篇文章主要介绍了Android调节屏幕亮度实现代码,调节屏幕亮度时,先设置当前activity亮度,再并保存为系统亮度即可,本文分别给出两个步骤的实现代码,需要的朋友可以参考下
    2015-05-05
  • Android自定义View获取注册验证码倒计时按钮

    Android自定义View获取注册验证码倒计时按钮

    这篇文章主要介绍了Android自定义View获取验证码倒计时按钮的制作方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-10-10
  • Android之Intent附加数据的两种实现方法

    Android之Intent附加数据的两种实现方法

    这篇文章主要介绍了Android之Intent附加数据的两种实现方法,以实例形式较为详细的分析了添加数据到Intent的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-09-09

最新评论