当前位置: 首页 > 软件库 > 手机/移动开发 > >

greedo-layout-for-android

授权协议 MIT License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 伯君浩
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Greedo Layout for Android

A drop-in custom layout manager for Android RecyclerViews to layout a grid of photos while respecting their aspect ratios.

Setup

Download the latest release via Gradle:

repositories {
	maven { url 'https://github.com/500px/greedo-layout-for-android/raw/master/releases/' }
}

dependencies {
	compile 'com.fivehundredpx:greedo-layout:1.5.1'
}

Usage

See the sample project for a complete solution on how to use GreedoLayout. Below are the specific steps.

// Create an instance of the GreedoLayoutManager and pass it to the RecyclerView
MyRecyclerAdapter recyclerAdapter = new MyRecyclerAdapter(this);
GreedoLayoutManager layoutManager = new GreedoLayoutManager(recyclerAdapter);

RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(recyclerAdapter);

// Set the max row height in pixels
layoutManager.setMaxRowHeight(300);

// If you would like to add spacing between items (Note, MeasUtils is in the sample project)
int spacing = MeasUtils.dpToPx(4, this);
recyclerView.addItemDecoration(new GreedoSpacingItemDecoration(spacing));

And then, in your RecyclerView adapter, or some other class of your choosing, implement SizeCalculatorDelegate. This implementation got passed to the layout manager above.

public class MyRecyclerAdapter extends RecyclerView.Adapter<ViewHolder> implements SizeCalculatorDelegate {
    @Override
    public double aspectRatioForIndex(int index) {
    	// Return the aspect ratio of your image at the given index
    }
}

License

GreedoLayout is released under the MIT license. See LICENSE for details.

  • 如何实现一个view或者layout,使它有一个最大高度?也就是说 当view的高度小于一个固定值(MAX_HEIGHT)时,view的高度采用自身高度(wrap_content)。 当view的高度大于一个固定值(MAX_HEIGHT)时,view的高度设置为MAX_HEIGHT,并且可以scroll。 我就写了这样一个layout: <ScrollView android:la

  • 在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById()。不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例化;而findViewById()是找xml布局文件下的具体widget控件(如Button、TextView等)。 具体作用: 1、对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutI

  •         Android开发过程中,经常会遇到像layout-sw600dp, values-sw600dp这样的文件夹,以前没用到,不怎么关注,所以一直一知半解的。现在要用到了,才去了解他们的用法和区别。其实,他们和drawable-hdpi/ drawable-mdpi等的使用类似,都是为了实现适配各种Android手机屏幕而使用的,只是drawable用来管理不同大小图片资源,layo

  • 今天在调试一个例子时,如下图   <TextView android:id="@+id/view_test01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text01" android:layout_x="50dip" andro

  • 滥用LAYOUT会导致initialization, layout and drawing become slower. 如果你在嵌套几个linearlayout时用到weight参数,他要求孩子被测量俩次,这尤其昂贵的。 在一个listview中,你假设让他的ITEM显示出下列的一种格式。 < LinearLayout xmlns:android = "http://schemas.androi

  •     表格布局是指该容器是一个表格,放置控件时,控件的位置坐落在表格的某个位置上。 其中TableRow是配合TableLayout使用的,目的是为了让TableLayout生成多个列,否则TableLayout中就只能存在一列元素,但可以有多行。

  • layout_centerVertical="true" works in a RelativeLayout while layout_gravity="center_vertical" works in a LinearLayout.

  • 场景 WebView子控件Button之属性android:layout_x与android:layout_y可调按钮位(屏幕左上角原点,右、下为X轴、Y轴正向): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" x

  • So I have the following layout ScrollView RelativeLayout TextView1 EditText1 TextView2 EditText2 TextView3 EditText3 TextView4 EditText4 TextView5 EditText5: android:id="@+id/txtPassword" LinearLayout

  • layout_alignStart是适应阅读习惯,android:layout_alignEnd是指本组件的末端和某组件末端对齐

  • 一、线性布局(LinearLayout)(比较重要) 1、LinearLayout是一个view组(view group),其包含的所有子view都以一个方向排列,垂直或是水平方向 2、在LinearLayout使用gravity属性是操控它内部的控件的位置,而TextView使用gravity属性是操控控件中文字的位置,而不能控件本身在布局中的位置改变。 注意: ①LinearLayout中所有

  •           相对布局是指利用控件之间的相对位置关系来对布局进行设置。 在容器中的控件与其他任何一个控件或者容器都有相对关系。           例如: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" a

  • 在Android中,如何获取在XML文件中设置的值? my_layout.xml: android:layout_width="300dp" android:layout_height="500dp" android:orientation="vertical" > ..... 我已经尝试了以下方法,但均未成功: View v = ((LayoutInflater) ctx.getSystemSe

  • 1.线性布局Linear Layout 按排列的方向(orientation)分为水平线性布局( android:orientation="vertical")和垂直线性布局( android:orientation="horizontal"//默认的是水平线性布局 )。 线性布局定义了排列方向后,会一直沿着该方向一直排列下去,除非利用嵌套再重新定义。 android:layout_weight=

  •            android:gravity="right"            android:layout_marginRight="16dip" 这两个属性,有时对Button无效,这时候需要外部套一个LInearLayout, 再给layout设置这两个属性。

 相关资料
  • The jLayout jQuery plugin provides two layout algorithms for laying out HTML elements in web pages. The first is border, which lays out components in five different regions and the second algorithm is

  • Item sizing All sizing and styling of items is handled by your own CSS. <div class="grid"> <div class="grid-item"></div> <div class="grid-item grid-item--width2"></div> <div class="grid-item

  • 命名 gitrepository-layout - Git Repository Layout 概要 $GIT_DIR/* 描述 一个 Git 仓库有两种不同的风格: 一个.git目录在工作树的根; 一个<project>.git是bare存储库的目录(即没有自己的工作树),通常用于与其他人交换历史记录,方法是将其推入并从中取回。 注意:您也可以在工作树的根目录中有一个纯文本文件.git,其中包含

  • dl, dd { margin-bottom: 0; } What you’ll learn How Flutter’s layout mechanism works. How to lay out widgets vertically and horizontally. How to build a Flutter layout. This is a guide to building layo

  • Arrange other widgets columns, rows, grids, and many other layouts. Single-child layout widgets Multi-child layout widgets See more widgets in the widget catalog. Single-child layout widgets Container

  • dl, dd { margin-bottom: 0; } What you’ll learn How Flutter’s layout mechanism works. How to lay out widgets vertically and horizontally. How to build a Flutter layout. This is a guide to building layo