More ConstraintLayout

This commit is contained in:
topjohnwu 2019-01-24 14:41:12 -05:00
parent b7f69238a1
commit d3ebd763a2
3 changed files with 148 additions and 123 deletions

View File

@ -10,7 +10,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.topjohnwu.core.container.Module; import com.topjohnwu.core.container.Module;
@ -193,7 +192,7 @@ public class ReposAdapter extends SectionedAdapter<ReposAdapter.SectionHolder, R
@BindView(R.id.version_name) TextView versionName; @BindView(R.id.version_name) TextView versionName;
@BindView(R.id.description) TextView description; @BindView(R.id.description) TextView description;
@BindView(R.id.author) TextView author; @BindView(R.id.author) TextView author;
@BindView(R.id.info_layout) LinearLayout infoLayout; @BindView(R.id.info_layout) View infoLayout;
@BindView(R.id.download) ImageView downloadImage; @BindView(R.id.download) ImageView downloadImage;
@BindView(R.id.update_time) TextView updateTime; @BindView(R.id.update_time) TextView updateTime;

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
style="?attr/cardStyle" style="?attr/cardStyle"
@ -13,101 +12,107 @@
android:layout_marginStart="@dimen/card_horizontal_margin" android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin" android:layout_marginTop="@dimen/card_vertical_margin"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeight"
card_view:cardCornerRadius="@dimen/card_corner_radius" app:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation"> app:cardElevation="@dimen/card_elevation">
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:paddingStart="10dp"
android:minHeight="?android:attr/listPreferredItemHeight" android:paddingTop="5dp"
android:padding="@dimen/card_layout_padding"> android:paddingEnd="10dp"
android:paddingBottom="8dp">
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="@dimen/card_textview_width" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false"/> android:textIsSelectable="false"
app:layout_constraintBottom_toTopOf="@+id/version_name"
app:layout_constraintEnd_toStartOf="@+id/checkbox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/version_name" android:id="@+id/version_name"
android:layout_width="@dimen/card_textview_width" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark" android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false" android:textIsSelectable="false"
android:textStyle="bold|italic"/> android:textStyle="bold|italic"
app:layout_constraintBottom_toTopOf="@+id/author"
app:layout_constraintEnd_toEndOf="@+id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title" />
<TextView <TextView
android:id="@+id/author" android:id="@+id/author"
android:layout_width="@dimen/card_textview_width" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/version_name"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark" android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false" android:textIsSelectable="false"
android:textStyle="bold|italic"/> android:textStyle="bold|italic"
app:layout_constraintBottom_toTopOf="@+id/description"
app:layout_constraintEnd_toEndOf="@+id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/version_name" />
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/author"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/> android:textIsSelectable="false"
app:layout_constraintBottom_toTopOf="@+id/notice"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/author" />
<TextView <TextView
android:id="@+id/notice" android:id="@+id/notice"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/description"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/remove_file_created" android:text="@string/remove_file_created"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red500" android:textColor="@color/red500"
android:visibility="gone"/> android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
<LinearLayout app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content" app:layout_constraintStart_toStartOf="@+id/title"
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/description" />
android:layout_alignBaseline="@id/title"
android:layout_alignParentEnd="true"
android:orientation="horizontal"
android:gravity="end">
<CheckBox <CheckBox
android:id="@+id/checkbox" android:id="@+id/checkbox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:focusable="false" android:focusable="false"
android:gravity="center" app:layout_constraintBottom_toTopOf="@+id/description"
android:padding="@dimen/checkbox_padding" app:layout_constraintEnd_toStartOf="@+id/delete"
tools:ignore="ContentDescription"/> app:layout_constraintStart_toEndOf="@+id/title"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView <ImageView
android:id="@+id/delete" android:id="@+id/delete"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:focusable="false" android:focusable="false"
android:gravity="center"
android:padding="@dimen/checkbox_padding"
app:srcCompat="@drawable/ic_delete"
android:tint="@color/icon_grey" android:tint="@color/icon_grey"
tools:ignore="ContentDescription"/> app:layout_constraintBottom_toBottomOf="@+id/checkbox"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/checkbox"
app:layout_constraintTop_toTopOf="@+id/checkbox"
app:srcCompat="@drawable/ic_delete"
tools:ignore="ContentDescription" />
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
style="?attr/cardStyle" style="?attr/cardStyle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -12,86 +10,109 @@
android:layout_marginStart="@dimen/card_horizontal_margin" android:layout_marginStart="@dimen/card_horizontal_margin"
android:layout_marginTop="@dimen/card_vertical_margin" android:layout_marginTop="@dimen/card_vertical_margin"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeight"
card_view:cardCornerRadius="@dimen/card_corner_radius" app:cardCornerRadius="@dimen/card_corner_radius"
card_view:cardElevation="@dimen/card_elevation"> app:cardElevation="@dimen/card_elevation">
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight" android:paddingStart="10dp"
android:orientation="horizontal" android:paddingTop="5dp"
android:padding="@dimen/card_layout_padding"> android:paddingEnd="10dp"
android:paddingBottom="8dp">
<LinearLayout
android:id="@+id/info_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false" /> android:textIsSelectable="false"
app:layout_constraintBottom_toTopOf="@+id/version_name"
app:layout_constraintEnd_toStartOf="@+id/download"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/version_name" android:id="@+id/version_name"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark" android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false" android:textIsSelectable="false"
android:textStyle="bold|italic" /> android:textStyle="bold|italic"
app:layout_constraintBottom_toTopOf="@+id/author"
app:layout_constraintEnd_toEndOf="@+id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title" />
<TextView <TextView
android:id="@+id/author" android:id="@+id/author"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark" android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false" android:textIsSelectable="false"
android:textStyle="bold|italic" /> android:textStyle="bold|italic"
app:layout_constraintBottom_toTopOf="@+id/description"
app:layout_constraintEnd_toEndOf="@+id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/version_name" />
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/no_info_provided"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false" /> android:textIsSelectable="false"
app:layout_constraintBottom_toTopOf="@+id/update_time"
app:layout_constraintEnd_toEndOf="@id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/author" />
<TextView <TextView
android:id="@+id/update_time" android:id="@+id/update_time"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark" android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false" android:textStyle="bold|italic"
android:textStyle="bold|italic" /> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/description"
app:layout_constraintEnd_toEndOf="@+id/title" />
</LinearLayout> <View
android:id="@+id/info_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintBottom_toBottomOf="@+id/update_time"
app:layout_constraintEnd_toEndOf="@+id/title"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toTopOf="@+id/title" />
<ImageView <ImageView
android:id="@+id/download" android:id="@+id/download"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_file_download_black" android:layout_marginStart="8dp"
android:tint="@color/icon_grey"
android:clickable="true" android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:focusable="false" android:gravity="end"
android:gravity="end" /> android:tint="@color/icon_grey"
app:srcCompat="@drawable/ic_file_download_black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/title"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>