| <?xml version="1.0" encoding="utf-8"?> | |
| <!-- | |
| ~ Copyright (C) 2018 The Android Open Source Project | |
| ~ Licensed under the Apache License, Version 2.0 (the "License"); | |
| ~ you may not use this file except in compliance with the License. | |
| ~ You may obtain a copy of the License at | |
| ~ http://www.apache.org/licenses/LICENSE-2.0 | |
| ~ Unless required by applicable law or agreed to in writing, software | |
| ~ distributed under the License is distributed on an "AS IS" BASIS, | |
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| ~ See the License for the specific language governing permissions and | |
| ~ limitations under the License. | |
| --> | |
| <layout xmlns:card_view="http://schemas.android.com/apk/res-auto" | |
| xmlns:bind="http://schemas.android.com/apk/res-auto" | |
| xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <data> | |
| <variable name="user" type="com.android.example.bindingdemo.vo.User"/> | |
| <variable name="clickListener" type="android.view.View.OnClickListener"/> | |
| </data> | |
| <android.support.v7.widget.CardView | |
| card_view:cardUseCompatPadding="true" | |
| card_view:contentPadding="8dp" | |
| android:orientation="horizontal" android:layout_width="wrap_content" | |
| android:id="@+id/root" | |
| android:focusable="true" | |
| android:gravity="center_vertical" | |
| bind:onClickListener="@{clickListener}" | |
| android:layout_height="match_parent"> | |
| <ImageView | |
| android:id="@+id/user_photo" | |
| android:backgroundResource="@{user.photoResource}" | |
| android:scaleType="fitCenter" | |
| android:layout_width="@dimen/user_photo" | |
| android:layout_height="@dimen/user_photo" /> | |
| <TextView | |
| android:layout_marginLeft="@dimen/user_name_margin_left" | |
| android:id="@+id/fullname" | |
| android:gravity="center" | |
| android:text='@{user.name.substring(0,1).toUpperCase() + "." + user.lastName}' | |
| android:layout_width="wrap_content" | |
| android:layout_height="match_parent" /> | |
| </android.support.v7.widget.CardView> | |
| </layout> |