This question already has answers here:
creating a strikethrough text?
(14 answers)
Closed 9 years ago.
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.
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
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.
make your custome view like stike image and make visible invisible as per your requirment over the current view
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.
Related
I have a RecyclerView list where some items (text) are too long for the width allowed by the device. I can use android:ellipsize="end" to indicate that the text is truncated but I want to be able to show user the whole text. I can use android:scrollHorizontally="true" and then the text will scroll but there is no visual indication for the user that he needs to scroll it and the text just looks truncated. What would be the good UX for this case? Thanks.
1、you can edit your textView like this
xml
<TextView
...
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="......"/>
It will auto scrollHorizontal,Or you can use a autoFitTextView in you list item,auto fit textview.
You can add android:scrollbars="horizontal" to your recyclerview to show the scrollbar.
Turned out that the solution is to wrap the item in HorizontalScrollView and set android:layout_gravity="fill_horizontal". This allows for scrolling and there is a horizontal scroll bar for long items.
So, after many investigations, I've found the problem solution:
This happens due to MARGINS and PADDINGS (and maybe other offset parameters) inside your TextView and its parents. Just remove them and see the result.
I hope it helped new googlers!
PS:
If you want to save your offset parameters try to change the layout width parameter inside your TextView and its parents to wrap content (but somewhere also try 0dp or match parent), it also worked for me. So your UI will look exactly as you want!
I would like to reproduce this layout :
The blue lists are not scrollable, but the red panel (probably LinearLayout) is.
I already tried two ListView but I don't think it is the good way to do this, it doesn't work.
I read an article that advised to add multiple items to a LinearLayout. But in doing so, how to handle events on a single item, or use a BaseAdapter ?
I know I'm a little vague, but I'm having a little trouble explaining what I really want, I started Android development a few days ago.
Thanks.
I don't think it uses any ListView.
You can probably create something like this by having the red panel be a LinearLayout or RelativeLayout that's inside a ScrollView, so that it scrolls.
Then the blue "list" is probably not a ListView if it doesn't scroll. I guess it's just a bunch of regular views. So, something like this (pseudo code)
<ScrollView>
<LinearLayout>
<whatever layout for the green cell>
<include layout="blue_cell>
<include layout="blue_cell>
...
</LinearLayout>
</ScrollView>
And then you just create a layout for your blue cell, see info here: http://developer.android.com/training/improving-layouts/reusing-layouts.html
If you have a variable number of blue cells, you can just have the ScrollView and LinearLayout in XML, and inflate the blue cells layout programatically and add them to the LinearLayout
I've seen many of questions for how to add TextView in a RelativeLayout programatically, but everybody adding it in LinearLayout with orientation vertical. Can any one suggest me or give me a link that how to add multiple TextView in RelativeLayout at right until it has space and then change the line.
I want a layout like this..
May be this works for you !
You can customize chips-edittext-library for your need. Customizing by setting background to transparent, and editable to false.
-> Or you can use any other library which is used for displaying emoticon in EditText and customize it according to your need. Like android-emoticon-edittext-spike
You can use the Flow Layout library that manages the view arrangement itself.
When there is no space left the added View is moved to the next line
I'm adding 2 different views in my ListView header view but for some reason it create a 20dp space between those 2 views. How should I remove it?
Thanks!
Edit : The 2 views I add don't have any top/bottom padding or margins, I'm asking if there is any special "feature" in the ListView headerView about space/separator between views.
Edit 2: it seems that the space between the view in my header view is tied to the dividerHeight parameter. Why? I mean it should only be applied as rows separator. Is there any way to remove it from my headerView and keep it as actual row separator ? headerDividersEnabled=false don't do anything.
try to set android:headerDividersEnabled="false" in the ListView
i have same issue i have added dynamic header to listview but on the start of activity it gives space on the top of headerview and we scroll listview then header view overlaps with it instead of going up.
I'm developing an android app with fragments. While most of my layouts are pre-determined in the XML, I would like to programmatically insert a new view between views that were already loaded in a LinearLayout at startup.
How do I go about with this?
Thanks
Its possible to specify index while u dynamically add a view to a LinearLayout.
Set height of the first view as
android:layout_height="0dp"
android:layout_weight="1"
Set height = wrap_content for the second view in XML
Then while u are adding new View dynamically, set its height = wrap_content and add it to the parent LinearLayout like this
parentLinearLayout.addView(childView, index);
//index = position where you want to insert the new view.
It might help you. :)
the red View should have the default setting View.setVisibility(View.GONE) right at the beginning. When its time to show up you can switch over to View.setVisibility(View.VISIBLE). I cant verify the solution right now, but it should do the trick. So in this case you are not inserting a new View but make an existing one visible.