[英]How to make a square to view a gallery?
im using this metod LINK for generated a recyclerview with GridLayoutManager to autospan columns but i fail to make a square dummy layout for holderview, My intention is to imitate a gallery using recyclerview, 即时通讯使用此方法链接与GridLayoutManager生成一个recyclerview来自动跨栏,但是我无法为holderview创建方形的虚拟布局,我的意图是使用recyclerview模仿画廊,
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/white"
android:orientation="vertical"
android:padding="1dp">
<ImageView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<TextView
android:id="@+id/card_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:singleLine="true"
android:text="folder"
android:textSize="12dp"
android:textStyle="bold"/>
</FrameLayout>
Check out this answer , but basically you can create a custom SquareRelativeLayout and then override the onMeasure method so that it's always square like this: 看看这个答案 ,但是基本上您可以创建一个自定义SquareRelativeLayout,然后重写onMeasure方法,使其始终像这样方形:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Set a square layout.
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.