自定义适配器(ListView)中的TextView权重不适用于一行文本

问题描述 投票:0回答:1

所以我有自定义适配器listView。我有TextView。我想从右边显示它(gravity.right)

但是,当我设置属性Gravity.Right(我也尝试动态更改它)但它不适用于单行文本和多行文本。就像在这张照片中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">


<TextView
    android:id="@+id/"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Acer"
    android:textColor="@color/"
    android:textSize="36sp"
    app:fontFamily="@font/" />

<TextView
    android:id="@+id/"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textColor="@color/"
    app:fontFamily="casual" />

<TextView
    android:id="@+id/"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:text="Lorem Ipsum is simply dummy text of"
    android:textColor="" />

enter image description here

android listview textview gravity
1个回答
0
投票
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="end"
    android:orientation="vertical"
    android:padding="15dp">


    <TextView
        android:id="@+id/"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:textColor="@color/"
        android:textSize="36sp"
        app:fontFamily="@font/" />

    <TextView
        android:id="@+id/"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:textColor="@color/"
        app:fontFamily="casual" />

    <TextView
        android:id="@+id/"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:gravity="right"
        android:textColor="@color/" />

</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.