I'm trying to achieve this:
on a ListView but can't quite get the restraints on the items in the row layout.xml right, anyone have a suggestion?
here is my photo_album_row_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/photoAlbumTitle"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:textColor="@android:color/black"
android:paddingBottom="@dimen/default_padding"
android:textStyle="bold"
/>
<TextView
android:id="@+id/photoAlbumDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:textColor="@android:color/black"
android:layout_below="@+id/photoAlbumTitle"
android:layout_toStartOf="@+id/viewPhotoAlbum"/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:id="@+id/viewPhotoAlbum"/>
<TextView
android:id="@+id/viewPhotoAlbumText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="12sp"
android:textColor="@android:color/black"
android:text="Open Album"
android:layout_alignStart="@+id/viewPhotoAlbum"
android:layout_alignEnd="@+id/viewPhotoAlbum"
android:layout_below="@+id/viewPhotoAlbum"/>
</RelativeLayout>
It seems to center the text okay if there's only the title displayed, otherwise there is overlap, this is what I mean:
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_toStartOf="@+id/imageLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/photoAlbumTitle"
android:textColor="@android:color/black"
android:text="Hello world its title"
android:textStyle="bold"
/>
<TextView
android:id="@+id/photoAlbumDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Hello world its description"
android:textColor="@android:color/black"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/imageLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentEnd="true"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/ic_launcher"
android:id="@+id/viewPhotoAlbum"/>
<TextView
android:id="@+id/viewPhotoAlbumText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_alignStart="@+id/viewPhotoAlbum"
android:layout_alignEnd="@+id/viewPhotoAlbum"
android:layout_below="@+id/viewPhotoAlbum"
android:textSize="12sp"
android:textColor="@android:color/black"
android:text="Open Album"/>
</RelativeLayout>
</RelativeLayout>