This question already has answers here:
Making TextView scrollable on Android
(32 answers)
Closed 4 years ago.
Scrollbar is showing but not working or scrolling as shown in image below
XML:
<TextView
android:id="#+id/text_view_dialog_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:hint="#string/rv_notes_content"
android:padding="5dp"
android:scrollbars="vertical"
android:minLines="10"
android:maxLines="10"
android:textSize="17sp" />
Where is something wrong and how to fix it?
Using scrollbar on textView
you have to add this line in java
textView.setMovementMethod(new ScrollingMovementMethod());
make sure you add that to your code:
yourTextView.setMovementMethod(new ScrollingMovementMethod());
Related
This question already has answers here:
TextView Marquee not working [duplicate]
(20 answers)
Closed 4 years ago.
i have tried to use marquee but its not working,please help to solve this
<TextView
android:id="#+id/text_from"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="#343d43"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="#id/text_to"
app:layout_constraintStart_toStartOf="#id/label_from"
app:layout_constraintTop_toBottomOf="#id/label_from" />
android:singleLine is Deprecated. Use
android:maxLines="1"
android:focusable="true"
FYI
You should add setSelected
Changes the selection state of this view. A view can be selected or
not. Note that selection is not the same as focus.
TextView text_fromOBJ=(TextView) findViewById(R.id.text_from);
text_fromOBJ.setSelected(true);
android:focusable="true"
android:focusableInTouchMode="true"
you need add this lines in java
TextView txtView=(TextView) findViewById(R.id.text_from);
txtView.setSelected(true);
This question already has answers here:
How to layout text to flow around an image
(9 answers)
Closed 6 years ago.
I am new in android so I am confuse in this design so please help me.
I want to design this type
Have you tried FlowTextView
How to use
Add to your XML layout with your child views inside it:
<uk.co.deanwild.flowtextview.FlowTextView
android:id="#+id/ftv"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="10dip"
android:src="#drawable/android"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="400dip"
android:padding="10dip"
android:src="#drawable/android2"/>
</uk.co.deanwild.flowtextview.FlowTextView>
Then in your code:
FlowTextView flowTextView = (FlowTextView) findViewById(R.id.ftv);
Spanned html = Html.fromHtml("<html>Your html goes here....");
flowTextView.setText(html);
Add the dependency:
compile 'uk.co.deanwild:flowtextview:2.0.2'
Output:
Enjoy...
This question already has an answer here:
How to align TextView around an ImageView?
(1 answer)
Closed 6 years ago.
I have TextView and custom view called StarRating.
There is code snippet:
<RelativeLayout
android:id="#+id/flowtextView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.app.views.StarRating
android:id="#+id/star_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_2sdp"
android:text="by Legacy Reviewer, April 11, 2014 from Chicago IL"
android:textSize="12sp"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/star_rating" />
</RelativeLayout>
Actual Result:
Expected Result:
The problem is that TextView is not wrapping the StarRating...
How can I do that ?
This is not HTML. In standard TextView text is layouted within TextView boundaries (rectangle), so this is working as expected. You cannot make it work differently as these views won't work that way and if they overlap they do not know about this anyway.
Another way to do it is add extra spaces in the beginning of your text. it's a little tricky though.
let me know if you want more details.
Try using android:gravity="center".
<RelativeLayout
android:id="#+id/flowtextView"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
This question already has answers here:
creating a strikethrough text?
(14 answers)
Closed 7 years ago.
I am new to Android. I Want to create an TextView like My Image.I search a lot, but I don't get Any Idea.
In My TextView how to draw a line on Text. Please help me.
Any Help will be Appreciated.
you can directly create this line in layout file like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/viewline">
<TextView
android:id="#+id/txts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello to all"
android:textColor="#000000"
android:layout_centerHorizontal="true"
android:textSize="25sp" />
<View
android:layout_width="150dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true"
android:background="#000000"></View>
</RelativeLayout>
which gives a view like:
try this :
tv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
For set Strikethrough.
textView.setPaintFlags(txtView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
textView.setText("10.00 AM");
For clear Strikethrough
textView.setPaintFlags(0);
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Horizontal scrolling text in Android
<TextView
android:id="#+id/dtitle"
android:layout_marginLeft="100dp"
android:text="Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
/>
This is my code in xml file
Do you mean like a marquee?