P
P
protoss54822014-10-26 14:46:52
Android
protoss5482, 2014-10-26 14:46:52

The background of the ListView element goes beyond the borders of the ListView, how to deal with this?

There is an Activity with an ActionBar in which the ListView is located. When the ListView is scrolled, the background of the ListView element will overlap with other elements. And this does not happen on all devices, the screenshot was taken from the Samsung Galaxy S5. On Nexus 5 (4.4.4), Samsunfg Galaxy S2 (4.1.2) it was not possible to catch this.
36f7c6a314e24fbf9b5fa65fe556e788.png
1 Action Bar:

<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
      ...
</style>

 <style name="Widget.AppTheme.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">#1ec983</item>
        <item name="android:backgroundSplit">#1ec983</item>
      	<item name="android:titleTextStyle">@style/TitleColor</item>
    </style>

2. LinearLayout
3. ListView
activity layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/CHAT_INFO"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:orientation="horizontal" >

        <!-- информация о чате -->
    </LinearLayout>

    <ListView
        android:id="@+id/CHAT_LIST"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:stackFromBottom="true" >
    </ListView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="#e8f9f2"
        android:orientation="vertical" >

       <!-- поле вводи и кнопка отправить-->
    </LinearLayout>

</LinearLayout>

ListView element markup
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingBottom="3dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical" >

        <ImageView
            android:id="@+id/ITEM_IMAGE"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="top"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="8dp"
            android:background="@drawable/chat_ava_me"
            android:padding="1dp"
            android:scaleType="center"
            android:src="@drawable/ic_ava_chat" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/chat_send_background" >

            <com.rockerhieu.emojicon.EmojiconTextView
                android:id="@+id/ITEM_MESSAGE"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:fontFamily="sans-serif"
                android:linksClickable="true"
                android:minLines="1"
                android:padding="6dp"
                android:text="Medium Text"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#363636"
                android:textSize="9pt" />

            <ImageView
                android:id="@+id/ITEM_MENU"
                android:layout_width="24dp"
                android:layout_height="32dp"
                android:layout_gravity="top"
                android:layout_weight="0"
                android:scaleType="center"
                android:src="@drawable/ic_action_overflow_chat" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="55dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_margin="5dp"
            android:gravity="center"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/ITEM_STATUS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:drawableLeft="@drawable/ic_chat_send_mark"
                android:drawablePadding="4dp"
                android:fontFamily="sans-serif-light"
                android:gravity="center_vertical"
                android:text="@string/chat_sent"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#898989"
                android:textSize="5pt" />

            <TextView
                android:id="@+id/ITEM_TIME"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-light"
                android:text="2:28 pm"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#898989"
                android:textSize="5pt" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lopatoid, 2014-10-30
@lopatoid

Try setting the ListView to android:layout_height="0dp"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question