Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mislavs/92523cd94cb7264e8278 to your computer and use it in GitHub Desktop.
Save mislavs/92523cd94cb7264e8278 to your computer and use it in GitHub Desktop.
Android databinding library demo layout file - displays book cover and details.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.msvs.bookshelf.fragments.BookDetailsFragment">
<data>
<variable
name="book"
type="com.msvs.bookshelf.model.entities.Book" />
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/book_detail_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/keyline_half_margin"
android:layout_marginTop="@dimen/keyline_half_margin"
app:imageUrl="@{book.coverImagePath}"/>
<!--Title and author -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/keyline_half_margin"
android:layout_marginTop="@dimen/keyline_half_margin"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/book_detail_title"
style="@style/DisplayTextViewStyle"
android:text="@{book.title}"
tools:text="Test title" />
<TextView
android:id="@+id/book_detail_authors"
style="@style/TitleTextViewStyle"
android:text="@{book.authorsConcat}"
tools:text="Test author" />
</LinearLayout>
<!-- Description -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/keyline_half_margin"
android:layout_marginTop="@dimen/keyline_half_margin"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/book_detail_description"
style="@style/BodyTextViewStyle"
android:text="@{book.description}"
android:textSize="16sp"
tools:text="Description text" />
</LinearLayout>
<!-- Publishing info -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/keyline_half_margin"
android:layout_marginTop="@dimen/keyline_half_margin"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/book_detail_publisher"
style="@style/PublisherTextViewStyle"
android:text="@{book.publisher}"
tools:text="Publisher" />
<TextView
android:id="@+id/book_detail_publish_date"
style="@style/PublisherTextViewStyle"
android:text="@{book.publishedYear}"
tools:text="2014" />
<TextView
android:id="@+id/book_detail_isbn_10"
style="@style/PublisherTextViewStyle"
android:text="@{book.isbn10}"
tools:text="ISBN 10" />
<TextView
android:id="@+id/book_detail_isbn_13"
style="@style/PublisherTextViewStyle"
android:text="@{book.isbn13}"
tools:text="ISBN 13" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment