我想为我的RecyclerView
创建自定义行。这里是我的自定义行布局:自定义行与循环ImageView和textview在Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="180dp"
android:layout_margin="5dp"
android:background="#00000000">
<FrameLayout
android:id="@+id/customLevelLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/levelImage"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_above="@+id/gameText"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@drawable/circular_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="1"
android:textColor="#fff"
android:textSize="45sp" />
<TextView
android:id="@+id/gameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center"
android:textColor="#000"
tools:text="Tracing" />
</RelativeLayout>
<ProgressBar
android:id="@+id/gameProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:indeterminate="true"
android:padding="45dp"
android:visibility="gone" />
</FrameLayout>
<ImageView
android:id="@+id/lockImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/lock_background"
android:padding="45dp"
android:src="@drawable/lock"
android:visibility="gone" />
</RelativeLayout>
这是它的样子:
的问题是,我必须定义自定义行的预定高度即170dp
目前。我因此面临两个问题:
1)如果我在小屏幕或平板设备上打开应用程序。自定义的行看起来很丑,即我松开了圆形的ImageView
。
2)如果布局有轻微变化,文本不会保留在中心位置。
它解决了。谢谢:) – XoXo
祝你好运。@ Hiren – KeLiuyue
位于布局底部的'ImageView'处于不可见状态,占据了完整的高度。该怎么办 ? @KeLiuyue – XoXo