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 7634215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:06:49+00:00 2026-05-31T07:06:49+00:00

I have a listview with custom rows. In the row there are these items:

  • 0

I have a listview with custom rows. In the row there are these items:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <ImageView
    android:id="@+id/imageView1"
    android:layout_width="10dp"
    android:layout_height="fill_parent"
    android:focusable="false"
    android:scaleType="fitXY">
   </ImageView>"

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textsll"
    android:layout_gravity="center_vertical"
    android:gravity="center_vertical"
    android:layout_marginLeft="5dp">          
  <TextView android:id="@+id/textView1" 
    android:layout_width="240dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:layout_alignParentBottom="true" 
    android:layout_alignParentTop="true"
    android:layout_centerVertical="true"
    android:maxLines="1"
    android:ellipsize="end">"
  </TextView>
  <TextView android:id="@+id/textView2" 
    android:layout_width="240dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/textView1"
    android:maxLines="1"
    android:ellipsize="end">
  </TextView>
  </RelativeLayout>

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textsll2"
    android:layout_gravity="center_vertical|right"
    android:layout_marginLeft="10dp">"
  <TextView android:id="@+id/textView3" 
    android:layout_width="40dp" 
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:paddingBottom="5dp"
    android:maxLines="1"
    android:ellipsize="end"
    android:gravity="center_vertical"
    android:background="#87EB81">
  </TextView>
  </LinearLayout>

</LinearLayout>

If both textviews has some content, they are centered vertically in the row (almost).

But if the lower textview is empty, I call:

            holder.textView2.setVisibility(View.INVISIBLE);
            holder.textView.setGravity(Gravity.CENTER_VERTICAL);

Still, the upper textview gets into the top of the row. Why?

enter image description here

If I set it to View.GONE, I get this, but I dont want the height of the row to change:

enter image description here

  • 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-05-31T07:06:50+00:00Added an answer on May 31, 2026 at 7:06 am

    Update:

    In a RelativeLayout, views are aligned with their parent, with the RelativeLayout itself, or with other views. For instance, we declared that the description is aligned with the bottom of the RelativeLayout and that the title is positioned above the description and anchored to the parent’s top. With the description GONE, RelativeLayout doesn’t know where to position the title’s bottom edge. To solve this problem, you can use a very special layout parameter called layout_alignWithParentIfMissing.

    This boolean parameter simply tells RelativeLayout to use its own edges as anchors when a constraint target is missing. For instance, if you position a view to the right of a GONE view and set alignWithParentIfMissing to true, RelativeLayout will instead anchor the view to its left edge. In our case, using alignWithParentIfMissing will cause RelativeLayout to align the title’s bottom with its own bottom.

    For more look at Layout Tricks: Creating Efficient Layouts

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

Sidebar

Related Questions

<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <ImageView android:id=@+id/venueImage android:layout_width=wrap_content android:layout_height=wrap_content/> </LinearLayout>
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I have a custom listview row whose XML has one ImageView and three TextViews
I have created a custom listview that is populated using a row.xml file. Each
I have a ListView which contains custom rows. This custom row has following UI
I have a listView with custom objects defined by the xml-layout below. I want
I have a listview with 200 items. I use a custom view for each
i have a listview with checkbox in each rows. i'm using custom cursoradapter and
I have a listView with custom rows containing buttons and I populate the listView
I have a listview with custom rows. In imageView1 I set an image, but

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.