Thursday, February 21, 2019

Clickable TextView

We want to click a TextView to do something, for example, to open new screen. Let add some lines code in to xml file
android:clickable="true"
android:onClick="click"

In code, add method click
public void click(View v) {
{
You can use this way to button without the line android:clickable="true" because it certainly have clickable feature.
 We can use this to a whole layout.
To keep textView from break lines if the text inside longer than it’s width, use this line
android:singleLine="true"
When you set textView single line but text inside too long, text will display like this.

Add this line to keep it show text to the edge of textView
android:ellipsize="none"

If you wan to fix number of line, use this

android:lines="2"

No comments:

Post a Comment