Solved

Border around ListView in Android app

Posted on 2013-06-20
3
2,438 Views
Last Modified: 2013-06-24
Hello Android Experts,

I have a ListView and for some reason I cannot get rid of a thick white border around it.  I've attached a screenshot too.  I would appreciate any guidance as to how I can get rid of the border.  Below is the XML of my ListItem.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:clickable="true"
    android:orientation="horizontal"
    android:paddingLeft="10dp"
    android:paddingTop="10dp" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:contentDescription="@string/hello_world"
        android:src="@drawable/logo1" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="14dp"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="10dp"
        android:text="@string/hello_world"
        android:textColor="@color/NormalText"
        android:textSize="18sp" />

</LinearLayout>

Open in new window

ListView-border.png
0
Comment
Question by:Modifier1000
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
PCableGuy earned 500 total points
Comment Utility
Try playing with the background color of your ListView in its XML to better match your ListItem

as in this example, the ListView has a black background, fills the parent, etc.

 <ListView
        android:id="@+id/listView2"
        android:background="#000000"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="2sp" >
    </ListView>
0
 

Author Closing Comment

by:Modifier1000
Comment Utility
I changed per your code, but got same result with the exception that the divider lines are no longer visible due to the background color being black now.

But I did change the background of the layout itself.  And got what I needed.  I guess your suggestion of "playing with the background color" got me to think about what was different from my other layouts.  It was the background image was missing.  My dumb mistake.

Thanks for the 2nd pair of eyes!
0
 
LVL 12

Expert Comment

by:PCableGuy
Comment Utility
Good, sometimes a little nudge helps.....thanks for the points.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now