2017-02-19 56 views
0

我有简单recycler_view_item,我已经得到了应表现出一定的量(像左)文本视图 recycler_view_item的TextView:TextView的内容对准左

<TextView 
    android:text="500" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/debtors_item_leftamount" 
    android:textSize="@dimen/debtors_left_amount_size" 
    android:layout_weight="1" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    app:layout_constraintRight_toLeftOf="@+id/debtors_item_arrow" 
    android:layout_marginEnd="32dp" 
    android:textAlignment="textStart" 
    android:layout_marginRight="32dp"/> 

是否有人知道如何使它是对齐左边就像在正确的形象?

我已经试过

android:textAlignment="textStart" 
android:textAlignment="viewStart" 
android:gravity=start, left, even top or any other 

什么也没有改变。

Image

回答

0

这应该工作

android:layout_width="match_parent" 

android:gravity="left" 
+0

我无法使用match_parent,因为此TextView的父项是整个recyclerView项目,并且还有其他元素 –

+0

但您给了我间接建议。我已经使用原始大小的宽度(例如50),然后将textAlignment设置为textStart并且它正常工作! –

0

这个怎么样?

您缠绕回收视图的内容以线性布局如下::

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_parent" 
    android:weightSum="10" 
    android:gravity="center"> 

    //use the weight to define the layout_width="0" and layout_weight of the child elements 
    //define weight as required as matching your requirements. 

    //example below for Image View you are using 
    <ImageView 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1.5" 
    android:src="@drawable/image" 
    android:gravity="center"> 

</LinearLayout> 

这会给你固定响应的宽度和高度从设备的角度为好。您将能够使用重力来定义元素的位置。