-4

I wanna achieve an horizontal line that strikes a whole view inside a ListView, so I give the effect of striking the whole element in the listview.

How can I achieve this? I have found how to make a line below the view, but not over it.

Example of a normal state view and a striked one

Kenny D.
  • 927
  • 3
  • 11
  • 29
  • But I think that is for adding a strikethrough over the text, I want to strike the whole view, let me upload a graphic example :) – Kenny D. Mar 25 '13 at 04:00

4 Answers4

2

This will create a strike out line on your view

  <View
          android:id="@+id/View_Strike"
              android:layout_width="match_parent"
              android:layout_below="@id/Layout_myRow"
              android:layout_height="1dp"
              android:background="@android:color/white" />

Now where you are designing a row layout for your listview. place this above view in such a way that it overlaps you Text View at the desired position in you Row Layout

and set its visibility Gone

Now depending on the Situation when you have to strike thru Your Item make its Visibility Visible

Surely is the solution !! i have used it in one of my app

DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
  • 1
    This is the way. Just remember that the parent layout have to be `RelativeLayout` to use `layout_below` on child +1 – gpasci Mar 26 '13 at 20:10
1

Don't think there is a standard fast way of doing such a thing, but you can always create a view of fill_parent width and 1dp height and strike the whole view centering it relative to its parent.

gpasci
  • 1,420
  • 11
  • 16
0

make your custome view like stike image and make visible invisible as per your requirment over the current view

Ankitkumar Makwana
  • 3,475
  • 3
  • 19
  • 45
0

I have found the answer, if someone founds this useful:

Create a FrameLayout, inside of it I put the LinearLayout (with my TextViews) inside of it, and then a View with height=1dp width=fill_parent, and gravity of center.

The FrameLayout actually was created to make multiple layer views so it was the perfect thing.

Also for the details, in the listAdapter I make the View visible or gone.

Kenny D.
  • 927
  • 3
  • 11
  • 29