简易的图片浏览功能

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowPicInfo.aspx.cs" Inherits="WebRoot.PictureScore.ShowPicInfo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../ClientRes/jquery-1.6.1.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
页面构建begin
var SellerScroll = function (options) {
this.SetOptions(options);
this.lButton = this.options.lButton;
this.rButton = this.options.rButton;
this.oList = this.options.oList;
this.showSum = this.options.showSum;
this.pList = this.options.pList;
this.pWidth = $("#" + this.pList).width();
this.iList = $("#" + this.options.oList + " > li");
this.iListSum = this.iList.length;
this.iListWidth = this.iList.outerWidth(true);
this.moveWidth = this.iListWidth * this.showSum;
this.dividers = Math.ceil(this.iListSum / this.showSum); //共分为多少块
this.moveMaxOffset = (this.dividers - 1) * this.moveWidth;

this.LeftScroll();
this.RightScroll();
};

SellerScroll.prototype = {
SetOptions: function (options) {
this.options = {
lButton: "leftbtn",
rButton: "rightBtn",
oList: "carousel_ul",
pList: "carousel_inner",
showSum: 1 //一次滚动多少个items
};
$.extend(this.options, options || {});

},
ReturnLeft: function () {
return isNaN(parseInt($("#" + this.oList).css("left"))) ? 0 : parseInt($("#" + this.oList).css("left"));
},
LeftScroll: function () {
var one=<%=index %>;
if (this.dividers == 1&&one==1) return;
var _this = this, currentOffset;
currentOffset = _this.ReturnLeft();

$("#" + this.lButton).click(function () {
currentOffset = _this.ReturnLeft();
if (currentOffset < 0) {
$("#" + _this.oList + ":not(:animated)").animate({ left: "+=" + _this.moveWidth }, "slow");
} else {
var a=<%=index %>;
if (a!='1') {//如果是不是第一页则调用上一页的方法
__doPostBack('btnPreviousGroup', '');
}

}
});
},
RightScroll: function () {

if (this.dividers == 1) return;
var _this = this, currentOffset;
$("#" + this.rButton).click(function () {
currentOffset = _this.ReturnLeft();
if (_this.moveMaxOffset - Math.abs(currentOffset) >= _this.pWidth) {
$("#" + _this.oList + ":not(:animated)").animate({ left: "-=" + _this.moveWidth }, "slow");
} else {
var a=<%=index %>;
var b=<%=Session["sum"] %>;
if (a!=b) {//如果是不是最后一页则调用下一页的方法
__doPostBack('btnNextGroup', '');
}

}
});
}
};
页面构建end
</script>
<style type="text/css">
#carousel_inner
{
width: 802px;
height: 602px;
overflow: hidden;
position: relative;
}
#carousel_ul
{
width: 99999px;
height: 600px;
position: relative;
}
#carousel_ul li
{
float: left;
width: 802px;
height: 602px;
display: inline;
}
</style>
</head>
<body style="height: 100%; margin: 10px; padding: 0px; font-size: 12px;">
<form id="form1" runat="server">

<div style="padding: 10 0 10 0; border: solid 1px silver; border-top: 0; margin: 1px;
height: 100%">
<div id="carousel_inner" style="margin: 0 auto; text-align: center; vertical-align: middle;">
<div id="leftbtn" style="position: absolute; z-index: 99999; height: 600px; width: 400px;
cursor: pointer; filter: alpha(opacity=0); opacity: 0; background-color: #FFFFFF;">
</div>
<div id="rightBtn" style="position: absolute; z-index: 99999; height: 600px; width: 400px;
cursor: pointer; left: 401px; filter: alpha(opacity=0); opacity: 0; background-color: #FFFFFF;">
</div>
<div style="width: 50px; z-index: 888; margin-top: 270px; left: 50px; position: absolute;">
<img id="leftbtn1" style="cursor: pointer; display: none; width: 70px;" alt="上一张"
src="../ClientRes/images/prev.png" />
</div>
<div id="carousel_ul" runat="server">
</div>
<div style="width: 50px; z-index: 999; margin-top: -330px; position: absolute; right: 90px;">
<img style="cursor: pointer; display: none; width: 70px;" alt="下一张" id="rightBtn1"
src="../ClientRes/images/next.png" />
</div>
</div>
</div>
<!-- 小图列表 -->
<div id="one" style="padding: 10 0 10 0; border: solid 1px silver; border-top: 0;
margin: 1px; height: 100%;" runat="server">
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<td align="center">
<div style="width: 12px; z-index: 888; margin-top: -25px; position: absolute; top: 693px;">
<!--小图上一组 -->
<button dojotype="dijit.form.Button" id="btnPreviousGroup" iconclass="dijitEditorIcon dijitEditorIconSave"
showlabel="true" runat="server" onserverclick="btnPreviousGroup_Click" style="background: url(../ClientRes/images/goleft2.gif);
width: 11px; height: 56px; border-style: none; cursor: pointer; background-repeat: no-repeat;" οnclick="javascript:if(1==1){__doPostBack('btnPreviousGroup_Click','');}">
</button>
</div>
</td>
<td align="center">
<!--小图缩略图列表 -->
<div id="minImg" runat="server" style="text-align: center; margin-top: 10px; padding: 0px 0px 20px 0px;
margin-bottom: 20px; text-align: center; margin-left: 20px; margin-right: 10px;">
</div>
</td>
<td align="center" style="margin-left: 20px;">
<!--小图下一组 -->
<div style="width: 12px; z-index: 888; margin-top: -25px; position: absolute;">
<button dojotype="dijit.form.Button" id="btnNextGroup" iconclass="dijitEditorIcon dijitEditorIconSave"
showlabel="true" runat="server" onserverclick="btnNextGroup_Click" style="background: url(../ClientRes/images/goright2.gif);
width: 11px; height: 56px; border-style: none; cursor: pointer; background-repeat: no-repeat;" οnclick="javascript:if(1==1){__doPostBack('btnNextGroup_Click','');}">
</button>
</div>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
$(function () {
var width = 796;
var height = 596;
$("#carousel_ul img").each(function () {
if ($(this).get(0).offsetWidth > $(this).get(0).offsetHeight) {
$(this).width(width + "px");
var vspace = height - $(this).get(0).offsetHeight;
$(this).css({ padding: vspace / 2 + "px " + "0px " + vspace / 2 + "px " + "0px" });
} else {
$(this).height(height + "px");
}
});
});
</script>
</form>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Android Studio中创建一个简单的图片浏览功能,你可以使用`GridLayoutManager`和`ImageView`结合`RecyclerView`来展示一组图片。以下是一个简化的步骤和代码片段: 1. 首先,确保你的项目已经添加了RecyclerView依赖。如果还没有,可以在build.gradle文件中添加: ```gradle dependencies { implementation 'com.android.support:recyclerview-v7:28.0.0' // 使用较旧版本是为了兼容,实际应用请使用最新版本 } ``` 2. 创建一个新的布局文件(例如:`activity_main.xml`),定义RecyclerView: ```xml <androidx.recyclerview.widget.RecyclerView android:id="@+id/image_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" /> ``` 3. 在Activity或Fragment中设置布局,并初始化RecyclerView: ```java RecyclerView recyclerView = findViewById(R.id.image_recycler_view); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); // 2表示每行显示2张图片 // 假设你有一个图片列表 List<String> imagePaths = ...; // 这里应该替换成实际的图片路径集合 // 创建一个适配器 ImageAdapter adapter = new ImageAdapter(imagePaths, this); recyclerView.setAdapter(adapter); ``` 4. 创建一个`ImageAdapter`,继承自`RecyclerView.Adapter`: ```java public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> { private List<String> imagePaths; private Context context; public ImageAdapter(List<String> imagePaths, Context context) { this.imagePaths = imagePaths; this.context = context; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_image, parent, false); return new ViewHolder(itemView); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { holder.imageView.setImageResource(imagePaths.get(position)); } @Override public int getItemCount() { return imagePaths.size(); } class ViewHolder extends RecyclerView.ViewHolder { ImageView imageView; ViewHolder(@NonNull View itemView) { super(itemView); imageView = itemView.findViewById(R.id.image_view); } } } ``` 在这个例子中,每个`item_image.xml`布局文件通常包含一个ImageView用于显示图片
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值