Android 图像在 Tiles 中显示
Android Images display in Tiles
我想将图像显示到像 windows phone 菜单这样的图块中。我们可以使用 AsymmetricGridView 库来做到这一点。但我想在单个图像视图中显示,而不是在 GridView 中显示。在 Single Imageview 中这样做,
是否可以在单视图或图像视图中这样做?如果是那么建议我怎么做?
您可以使用 StaggeredGrid 或 PinterestListView。请访问以下链接:
https://github.com/etsy/AndroidStaggeredGrid
参考这个,它可能对你有帮助
https://github.com/jacobmoncur/QuiltViewLibrary
为此,您可以使用 AsymmetricGridView
。
实现多列和可变大小的 Android 自定义 ListView elements.Please 请注意,它当前处于预览状态。这基本上意味着 API 不是固定的,你应该期待版本之间的变化。
首先从这里添加库:https://github.com/felipecsl/AsymmetricGridView。
然后在布局文件中添加:
<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
并且在你的 activity class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (AsymmetricGridView) findViewById(R.id.listView);
// Choose your own preferred column width
listView.setRequestedColumnWidth(Utils.dpToPx(this, 120));
final List<AsymmetricItem> items = new ArrayList<>();
// initialize your items array
adapter = new ListAdapter(this, listView, items);
AsymmetricGridViewAdapter asymmetricAdapter =
new AsymmetricGridViewAdapter<>(this, listView, adapter);
listView.setAdapter(asymmetricAdapter);
}
切换到 enable/disable 元素重新排序以更好地填充网格:
// Setting to true will move items up and down to better use the space
// Defaults to false.
listView.setAllowReordering(true);
listView.isAllowReordering(); // true
享受你的代码:)
我想将图像显示到像 windows phone 菜单这样的图块中。我们可以使用 AsymmetricGridView 库来做到这一点。但我想在单个图像视图中显示,而不是在 GridView 中显示。在 Single Imageview 中这样做,
是否可以在单视图或图像视图中这样做?如果是那么建议我怎么做?
您可以使用 StaggeredGrid 或 PinterestListView。请访问以下链接:
https://github.com/etsy/AndroidStaggeredGrid
参考这个,它可能对你有帮助
https://github.com/jacobmoncur/QuiltViewLibrary
为此,您可以使用 AsymmetricGridView
。
实现多列和可变大小的 Android 自定义 ListView elements.Please 请注意,它当前处于预览状态。这基本上意味着 API 不是固定的,你应该期待版本之间的变化。
首先从这里添加库:https://github.com/felipecsl/AsymmetricGridView。
然后在布局文件中添加:
<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
并且在你的 activity class:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (AsymmetricGridView) findViewById(R.id.listView);
// Choose your own preferred column width
listView.setRequestedColumnWidth(Utils.dpToPx(this, 120));
final List<AsymmetricItem> items = new ArrayList<>();
// initialize your items array
adapter = new ListAdapter(this, listView, items);
AsymmetricGridViewAdapter asymmetricAdapter =
new AsymmetricGridViewAdapter<>(this, listView, adapter);
listView.setAdapter(asymmetricAdapter);
}
切换到 enable/disable 元素重新排序以更好地填充网格:
// Setting to true will move items up and down to better use the space
// Defaults to false.
listView.setAllowReordering(true);
listView.isAllowReordering(); // true
享受你的代码:)