Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:59:29+00:00 2026-06-15T00:59:29+00:00

I am attempting to vertically centre a TextView element within a listview row. The

  • 0

I am attempting to vertically centre a TextView element within a listview row. The left hand side of the image shows the list view, in the first view the textview has the value “MSH”

As the image shows this is not quite in the centre, it is slightly too high.

The layout view for the textview row is shown below.

How do I get the textview centred?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:tools="http://schemas.android.com/tools"                                       android:orientation="horizontal"
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_marginRight="5dp"
xmlns:android="http://schemas.android.com/apk/res/android">

        <TextView android:id="@+id/tvName" 
            android:gravity="center_vertical"
            android:layout_width="95dp" 
            android:layout_height="40dp" 
            android:layout_marginLeft="10dp" 
            android:text="XXX"
            android:textSize="30sp"  
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView android:id="@+id/tvLongName"
            android:layout_toRightOf="@+id/tvName"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="dfdfdsfdfdfdsfdsf" 
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView android:id="@+id/tvUsage" 
            android:layout_below="@+id/tvLongName"
            android:layout_toRightOf="@+id/tvName"
            android:layout_height="wrap_content" 
            android:layout_width="10dp"
            android:layout_marginRight="5dp"
            android:gravity="right"
            android:text="R" 
            android:textAppearance="?android:attr/textAppearanceMedium" />  

        <TextView android:id="@+id/tvCardinality" 
            android:layout_below="@+id/tvLongName"
            android:layout_toRightOf="@+id/tvUsage"
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:layout_alignParentRight="true" 
            android:layout_marginRight="5dp"
            android:text="(0..1)" 
            android:textAppearance="?android:attr/textAppearanceMedium"  />

   </RelativeLayout>

Screenshot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:59:30+00:00Added an answer on June 15, 2026 at 12:59 am

    Instead of using android:gravity="center_vertical"

    you should use android:layout_centerVertical="true"

    That will do the trick surely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to correctly vertically align offsetting elements using Twitter Bootstrap with a fluid
Attempting/struggling to get registration and sign-up working within an active admin project. I have
I am attempting to render a UI using Sproutcore where I have a list
I am attempting to create my own view in android which is simply an
Attempting to print out a list of values from 2 different variables that are
I am attempting to build a Tabbed side navigation menu using html/css. I am
I'm attempting to use a class extending view to add a canvas and then
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Attempting to set up an automated texting service for customers, where people can text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.