Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MovieHunt blog part5. data binding xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="movieId"
type="String" />
<variable
name="posterImage"
type="String" />
<variable
name="title"
type="String" />
<variable
name="rating"
type="String" />
<variable
name="clickListener"
type="com.enginebai.moviehunt.ui.MovieClickListener" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> clickListener.onMovieClicked(movieId)}"
>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/cardPoster"
app:cardBackgroundColor="@color/darkBlue"
app:cardCornerRadius="@dimen/corner"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintDimensionRatio="1:1.5"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imagePoster"
android:scaleType="centerCrop"
android:src="@color/darkBlue"
app:imageUrl="@{posterImage}"
app:error="@{@color/darkBlue}"
app:placeholder="@{@color/darkBlue}"
/>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textTitle"
style="@style/TitleText.Normal"
android:layout_marginTop="@dimen/size_8"
android:text="@{title}"
app:layout_constraintTop_toBottomOf="@+id/cardPoster"
tools:text="Avengers: III"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textRating"
android:layout_marginTop="@dimen/size_4"
android:drawableStart="@drawable/thumbs_up"
android:text="@{rating}"
style="@style/ContextText"
tools:text="89.6%"
app:layout_constraintTop_toBottomOf="@+id/textTitle"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment