I have a problem with TextView that has ScrollBar. I know that in order to create scrollbar on the textview, I need to enable this on the xml:
android:scrollbar="vertical"
and in the code.java, I set like this:
tvChapterDesc.setMovementMethod(new ScrollingMovementMethod())
Then, now user could scroll the TextView, if it is more than the defined number of lines. (say maxlines = 5).
However, I have a Button where if it is clicked, it is supposed to scrolled the textview to the top, can I do this? How? For example that the textview has 1000 lines, and there is a button "top". if user click button "top", it will be scrolled to the top immediately, so user can start reading to the beginning of the textview again. How to do that?
You should be able to use the scrollTo function on the textView.
Related
The title may not be accurate but here is what I want to achieve:
I have a layout header.xml which looks like this:
Now I want to control the display of a textview below the icon programatically. Below is how it looks when the textview is set to view.VISBILE:
I include this header in my Activity layout. I have a text view in my activity which has a top margin of 150dp. So, when I set the visibility of the icon's textview dynamically, the text in my activity is coming down. See below two images for comparision:
But even when the icon's textview is visible, I want the "Hello World" text to stay at 150dp distance w.r.t header when the icon's textview is set to view.GONE. So, I am looking for a kind of a floating view or something similar which will not take up space in the layout dimensions.
Note: This requirement is similar to a tooltip but I don't want to use any tooltip library.
I have a RecyclerView which is populated with items each containing a TextView. I call textView.setTextIsSelectable(true) on the TextView to make its text selectable, but I notice that when I tap on the TextView, or long press it to select text, the RecyclerView suddenly scrolls up so that the whole TextView is visible. I want to know how to disable this behaviour, so that touching or long pressing the TextView does not cause any scrolling.
I'm trying to find the best approach to handle a user clicking a button, setting the text of that button to (in my attempt) a textview and then automatically move onto the the next textview to update on the next button press.
At the moment I can do this by manually specifying each element by ID to update but there must be a better way, or a different approach.
An example: imagine a table with 2 rows of each 4 columns (each contains a textview) and below that 6 buttons. When any button is pressed the first time the textview of the first column is set to the button text, the next press of any button sets the the textview of the second column is set to the button text, and so on. When a row is complete it will start back at column one of the next row.
at the moment I'm using a hard coded function triggered by the onclick event, I realized that I could implement some counter and user row[i]_col[j] (or such) but is there a better way to approach this (eg. some way similar to changing focus on edittext)?
public void setValue(View view) {
TextView textView = (TextView) findViewById(R.id.textView_row1_col1);
textView.setText(((Button) view).getText());
}
If i understood your problem correctly ,
I would suggest using an array of Textviews instead of using findviewbyid so much (very pricey memory wise )
TextView [][] txtArr = new TextView[XSize][Ysize];
Initial that in the start once and use it in the on click later.
In android app, I have display the number of buttons in number of rows in GridView using adapter, If i click the button in first row right corner automatically the second row buttons are moved to first row and hide the first row buttons by second row buttons. i need to fix the solution for, the button is not move.
Anyone can give idea to fix the solution for this?
1. Use fixed size Buttons.
2. The professional way to handle it, is usingIcons Images.
In GridView display the buttons inside the EditText and and set the background color as white for EditText, Now the buttons are not moving when click the button in first row on the GridView.
all,
We know on Andorid, for a EditText, by default, whenever the EditText is clicked, the soft keyboard pops up to let you enter text. When you click DONE, it closes out and put the text directly to the EditText.
Now, what I am trying to do is, instead of an EditText, I have an ImageView which is to let user enter some comment.(So the ImageView actually is an comment icon). I wish whenever the icon is clicked, it pops up the text editor with user previous entered text, again once the DONE is hit, it closes out and I can save whatever text there back to a string member of the Activity. Is that possible?
So far, all I've seen about InputMethodManager is on EditText control, If it is too complicated, I probably just put an EditText into a sperate Activity.
Thanks.
There are many solutions:
One is to use custom dialog: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Second one is to use a transparent activity on top of that one.
Then you could use FrameLayout and insert another view in an exact position...
I think you should try the frist or second one. Every ImageView can be easily converted into a button by adding onClick event to it.