Horizontal checked line android textview - android

This might be a simple question but I am not able to find a solution after hours of search.
How to achieve Strikethrough effect on the TextView given in the image below. The line length should be same as the text length.

TextView textview = (TextView) findViewById(R.id.textview);
textview.setPaintFlags(textview.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
textview.setText(someString);
Make sure your textview width is WRAP_CONTENT.

Related

Wrapping content height on a SnackBar

is there any way to make a SnackBar wrapping its text content?
You can look up my problem below:
As you can see the text ends at "contact us at...." and it should display the entire message.
Thank you!
I believe that snackbar by default limits you to only 2 lines.
One thing that you could try is setting the textview inside snackbar to be multiline. Like so:
View snackbarView = snackbar.getView();
TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setMaxLines(5); //set the max lines for textview to show multiple lines
Let me know if that works or not

Non-rectangular TextView

I tried searching for a solution, but I couldn't find anything of the sort.
My quest is: is it possible to have a non-rectangular TextView? I need to put a TextView and an ImageView inside a fragment.
Would look something like this:
I was thinking of maybe having two TextViews (lets call them tv1 and tv2) and an ImageView (Img1).
I could align the tv1 to the bottom of img1 and align the top of tv2 with img1. SOMEHOW play with the text in the TextViews to split it in both TextViews?
Flow textview will help to acheive what you want. Here are the few links
http://grishma102.blogspot.in/2013/12/how-to-make-text-flow-around-images-in.html
https://code.google.com/p/android-flowtextview/

Android Linkify in nested RelativeView

I have a LinearLayout/Scrollview/LinearLayout in which I need two links.
first is a regular TextView - that works fine.
SECOND TextView is in a RelativeLayout with an ImageView left from it, that's not working.
(LinearLayout/Scrollview/LinearLayout/RelativeLayout
ImageView TextView*
)
TextView first = (TextView) v.findViewById(R.id.first_tv);
TextView second = (TextView) v.findViewById(R.id.second_tv);
first.setText(Html.fromHtml(getString(R.string.url_first)));
Linkify.addLinks(first, Linkify.ALL);
second.setText(Html.fromHtml(getString(R.string.url_second)));
Linkify.addLinks(second, Linkify.ALL);
first textview click works.
Why does the second textview look like it's a link but it's not opening the browser on click?
add
second.setMovementMethod(LinkMovementMethod.getInstance());

How to get TextView reference from a custom ImageView?

I would like to ask if there is any methods to get a View from another View.
My case is that:
I have a custom ImageView call MyImageView.
and my layout is that:
FrameLayout:
MyImageView
LiearLayout:
LiearLayout:
TextView
LiearLayout:
TextView
I have some code in MyImageView and I would like to edit the text in TextView under the LinearLayout.
my code in MyImageView for select the TextView is:
TextView textView = (TextView) findViewById(id.TextView01);
However textView is always null and I can't set the text that I prefered.
More, if I code this:
TextView textView = (TextView) findViewById(R.id.TextView01);
Eclipse will give me a error and said can;t resolve the id.
So Is there any methods to edit TextView from a ImageView?
First of all... that's a horrible idea (I would be freaked out if I were you). And it's big signal that you have to rethink how to do your layout.
Anyway, using the getParent method could work:
// in your MyImageView
FrameLayout parent = (FrameLayout)getParent();
TextView textView = (TextView) parent.findViewById(R.id.TextView01);
It's not working the way you are doing it, since the TextViews are not inside your custom view.
I think you can always call getRootView() and from there you can search for a view by Id. As long as the ids are unique within the current view hierarchy you should be able to grab the textView no matter where it is in the hierarchy.
So similar to the other answer
TextView textView = (TextView) getRootView().findViewById(R.id.textview_01);
if it's on the same screen, it will be there always.

How to align TextView in android

I am adding Linearlayout dynamically and adding 3 TextView getting the content from webservices for text view if the content of 3 text size is larger it will display in the end of next line .i want display in start line how can i do?
Thanks
TextView header_text;
header_text = (TextView) findViewById(R.id.header_text1);
header_text.setSingleLine();
try to use android:gravity="left" or alignParent="left"
To align your Text inside a specific TextView:
Textview t = (Textview) findViewbyid(R.id.yourView); //refernce to your View
t.setGravity(Gravity.RIGHT); //or any align you want
t.setText("String text or long string");

Categories

Resources