Deejaygeekout
Deejaygeekout

Reputation: 242

Dynamic overlapping tab host

So I have tried horizontal listview (adapter), but I cannot get the padding in the left so it will overlap each other. it's just separated like in wrap content. any suggestion on how to do this dynamically?

http://www.bild.me/bild.php?file=8656221tabs.jpg

I even tried dynamic addview

   <LinearLayout
            android:id="@+id/frag_productline_list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
        </LinearLayout>

    for (int i = 0 ; i < productList.size(); i++){

            TextView tv = new TextView(context);
            tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT) );
            tv.setPadding(-40, 0, 0, 0);
            tv.setText(productList.get(i));
            tv.setBackgroundResource(R.drawable.tab);
            layout.addView(tv);
    }

But it looks like just an adapter I've tried in horizontal list view . Even worse with no handling of onItemClickListener

Upvotes: 1

Views: 63

Answers (2)

josephus
josephus

Reputation: 8304

You can't overlap views by setting a negative padding. However, you can give them a negative margin.

LayoutParams lp = tv.getLayoutParams();
lp.setMargin(negative left margin, top, right, bottom);
tv.setLayoutParams(lp);

Upvotes: 1

Alex Sales
Alex Sales

Reputation: 176

I suggest having an absolute layout/relative layout and scroll view instead of horizontal list view. Programmatically append the image buttons in an overlapped manner.

Upvotes: 1

Related Questions