Answer the question
In order to leave comments, you need to log in
How to align RecyclerView element to its right edge?
The situation is that certain elements need to be right aligned on the RecyclerView , but I don't understand how, none of these attributes:
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
Together, or not together, they don’t work, margin works, but I don’t see the point in calculating the indents, when most likely it is possible to do everything calmly with one attribute, without
ps numbers For the elements of the right and left edges, their own templates have been created
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/ivAvatar"
android:layout_width="@dimen/size_avatar_imageview"
android:layout_height="@dimen/size_avatar_imageview"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/tvPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="@string/unidentified_user"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
</LinearLayout>
<TextView
android:id="@+id/tvText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="New Text"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
</android.support.v7.widget.CardView>
Answer the question
In order to leave comments, you need to log in
Everything is working. Everything is right.)
In general, everything is done like this:
we make the layout of the RecyclerView element.
For example
<LinearLayout ...>
<CardView>
<TextView />
</CardView>
</LinearLayout>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question