mercredi 20 mai 2015

How do I clip child elements in a popup window having rounded corner to avoid overlapping of element's background color with round border?

I am having a TextView and a ListView in a PopupWindow (round corner). But the TextView and the ListView are shown outside the Popup's border.

enter image description here

I need no padding. I want the ListView to scroll smoothly but hidden beyond the border.

popup.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:orientation="vertical"
    android:background="@drawable/round_corner_popup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="#000"
        android:textColor="#FFF"
        android:text="Popup Window"
        android:gravity="center" />

    <ListView
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:id="@+id/popup_listView" >
    </ListView>

</LinearLayout>

round_corner_popup.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg"
    android:shape="rectangle">

    <corners android:radius="50dp" />

    <stroke
        android:width="3dp"
        android:color="#80000000" />

    <solid android:color="#50000000" />
</shape>

row_listview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="100dp">

    <ImageView
        android:layout_margin="5dp"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:id="@+id/listView_imageView"
        android:src="@drawable/abc_btn_check_to_on_mtrl_000" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <TextView
            android:id="@+id/listView_largeText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Heading Text"
            android:textStyle="bold"
            android:textColor="#000"
            android:textSize="26sp" />
        <TextView
            android:id="@+id/listView_smallText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Heading Text"
            android:textSize="18sp" />

    </LinearLayout>

</LinearLayout>

Aucun commentaire:

Enregistrer un commentaire