Reputation: 629
friend's, I have task to set menus in horizontal scrolling with images at two ends to show availability of menus. I did it by using gallery view, but i need to place an seperator (Vertical Line) between menus,i can't able to get the seperator in between the gallery. How can i get it.
i need the view below
----------------------------------------
< menu1 | menu2 | menu3 >
-----------------------------------------
just refer CBSNews application if u have.
Thanks in advance.
Upvotes: 1
Views: 4082
Reputation: 5396
Basically the idea is to include the separator into the layout for the gallery items, e.g:
<View android:id="@+id/separator" android:background="#000"
android:layout_height="80dip"
android:layout_marginLeft="5sp" android:layout_marginRight="15sp"
android:layout_width="3sp"
android:layout_alignParentLeft="true"></View>
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="100dip"
android:layout_toRightOf="@id/separator"
android:layout_height="80dip" xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/imageView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside"></ImageView>
</RelativeLayout>
Then, in your SimpleAdapter-derived class, hide the separator for the item with position 0:
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
View separator = view.findViewById(R.id.separator);
if ( separator != null)
separator.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
return view;
}
Set the gallery spacing such that it corresponds nicely with the margins set to the separator in the layout.
Upvotes: 1