[英]Why this layout dont align the content of textview vertically?
Why this layout dont align the content of textview vertically? 为什么这种布局不能垂直对齐textview的内容?
I already tried change by code too and few another things in XML, but nothing solved my problem. 我已经尝试过通过代码进行更改,并尝试使用XML进行其他操作,但是没有任何方法可以解决我的问题。
This layout is for an adapter for a ListView. 此布局用于ListView的适配器。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_lista_classe_personagem_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:layout_margin="5dp" > <ImageView android:id="@+id/imageCover" android:layout_width="70dp" android:layout_height="70dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:contentDescription="@string/sem_imagem" /> <TextView android:id="@+id/textView" android:layout_toRightOf="@+id/imageCover" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:text="@string/app_name" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="@color/Red" /> </RelativeLayout>
Where I change string by code: 我在哪里通过代码更改字符串:
TextView textView = (TextView) view.findViewById(R.id.textView);
textView.setText(classePers.getNome());
textView.setGravity(Gravity.CENTER_VERTICAL);
ImageView is inside your RelativeLayout. ImageView在您的RelativeLayout中。
Instead, replace the line 相反,替换行
android:gravity="center_vertical"
BY 通过
android:layout_centerVertical="true"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.