Reputation: 305
Why this layout dont align the content of textview vertically?
I already tried change by code too and few another things in XML, but nothing solved my problem.
This layout is for an adapter for a 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);
Upvotes: 0
Views: 51
Reputation: 3873
ImageView is inside your RelativeLayout.
Instead, replace the line
android:gravity="center_vertical"
BY
android:layout_centerVertical="true"
Upvotes: 3