开发者

Android -- How to remove that little extra padding when using a ListView with custom background?

开发者 https://www.devze.com 2023-03-17 09:41 出处:网络
I have the following layout: <?xml version=\"1.0\" encoding=\"utf-8\"?> <FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"

I have the following layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:background="#EAEAEA">

  <ListView  
        android:id="@+id/xxx"
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent"
        android:textColor="#464C59"         
        android:divider="#A4C539"
        android:dividerHeight="1px">
   </ListView>

    <ImageView
        android:id="@+id/home_bottom_bar"
        android:src="@drawable/bottombar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:clickable="true"/>
</FrameLayout>

The goal is to have some sort of advertising bar at the bottom of the activity (which contains a list of items). It works ok, except for one thing! There is some sort of extra space just under the bar (it's very small but it's noticeable enough). By the way, all the paddings are set to 0 so where does this space come from?

Thanks!

EDIT

After investigating the issue, it turns out that the custom background (#EAEAEA) is 开发者_JAVA百科causing this extra space. Still don't know how to fix this though.


When you mention that it is a small extra space, it may be the tiny gradient at the top and bottom. Created by ListView, when it is made scrollable.

You may read about ListView Backgrounds, this should give you the idea on how to fix it, if it is caused by this special gradient.

This gradient line can apparently also be removed: extra line in tab host


You may want to use the merge tag since every activitys base layout is a FrameLayout. (This may cause the padding. Im not 100% sure on this one though) Look here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号