Created
December 8, 2020 14:48
-
-
Save enginebai/7f0298d224edce10385ecd41fdda245f to your computer and use it in GitHub Desktop.
MovieHunt blog part5. data binding xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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