android edittext and textview scroll together - android

I have a edittext and textview next to each other. I'd like, when I scroll with the edittext(either with finger or by adding new content to edittext) that the textview scroll the same distance. I've tried querying the getScrollY

I am not sure if I understand your question perfectly, but if I do, then I would suggest putting these two elements side by side in a Horizontal linear layout within a Scroll View. This way if / when either of the elements are moved, they will stay with each other.

Related

How can I disable ScrollView scrolling if it's not needed?

My UI consists of a ScrollView that takes the top 50% of the screen and under that two buttons that are attached to the bottom of the screen; YES and NO. The content of Scrollview is text that for most phones does not fill up the visual area of the ScrollView. However sometimes the text can be longer, such that it fills beyond the visual area of the ScrollView, hence the reason I added the ScrollView.
My problem is this; even when the ScrollView has very little text and does not need to scroll to show all of its content it still scrolls. The user can scroll the content up a slight amount. I'd like the View to instead not allow any scrolling if all the content is visible.
Is there an easy way to achieve this? Or do I have to implement that myself?
You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched. To get help with extending, please read the answers to Disable ScrollView Programmatically?

Make middle View not push other view outside of bounds

I have multiple TextViews inside a horizontal LinearLayout and i need the middle text view to have ellipse=middle so that when the middle text is long enough, it pushes on both sides but the other views don't go out of bounds, but instead the middle TextView shows the '..."
Here's how it should look.
Setting the items normally, wrap_content for all in a horizontal LinearLayout will make the at ASAP text be pushed outside of the screen on Android (the above screens are from the iOS app).
Any ideas on how to accomplish this? Perhaps with a ConstraintLayout somehow ?!
Yes, i would recommend a ConstraintLayout. Top item to the top of the view, bottom item to thr bottom of the view then the middle item attached to these two views. You could also use barriers.

How to create two dimensions scrollable table(view) with onclicks

I need to create large table with horizontal and vertical scrolling. Each cell of this table should be clickable.
To make it clear this is a picture of what I am trying to achieve. Scrollable area on the center, empty cells and cells with numbers should be clickable.
I've tried different approaches, but all end up failed:
GridView:
Problem: gridview elements are clickable and scrollable, but scroll is only vertical.
HorizontalScrollView is placed in VerticalScrollView, while LinearLayout, which represents a table row, is placed in HorizontalScrollView. And program built table adds new Linearlayouts row by row. Scrolling is implemented manually in a parent layout by setting coordinates to scroll views in TouchEvent. I'm using custom ScrollViews which return false in ontouchevent to set coordinates in parent. Scrolling works fine, but when we attach onClickEvent to a cell(textview), it breaks. Clicking works, but scrolling doesn't. I've tried different modifications (onintercepttouchevent) of this approach, but best result was scroll causing click after scrolling.
Also table header should be fixed vertically.
The first and last column should be fixed horizontally.
I wonder how Google made this in Google Docs app. Their table is perfectly scrollable and clickable.
I found working solutuion. Instead of OnTouchEvent I use onScrollChanged and onHorizontalScrollChanged for manual scroll. With this approach clicking works fine but doesn't work diagonal scroll, because event parameter x is always 0 in onScrollChanged(and opposite in onHorizontalScrollChanged).

RelativeLayout android:clipChildren="false" does not work: Animation will get clipped?

I am trying to implement a scrolling "newsbar". There is a RelativeLayout which fills the screen horizontally. It should contain many different news titles, contained by TextView objects, which I download from the internet and they should be animated in order to slowly moving from right to left, which will generate a "scrolling newsbar" effect. I place the first TextView as RelativeLayout.ALIGN_PARENT_LEFT and all the consecutive TextViews aligned as RelativeLayout.RIGHT_OF according to the previous TextView. So, the text would enter from the right side of the screen and flow through the layout and finally exit from the left side.
I see that the RelativeLayout clips children which are outside of its bounds. I set android:clipChildren="false" for this purpose but it does not function and the TextViews continue to get clipped, which is very annoying and is currently blocking my progress.
Is this a bug or am I doing something wrong?
Please help me...

(Android) How to put a TextView int the Center of the screen (Not in the Layout or Parent View) if I have a Horizontal Scroll?

This is my problem: I have a (horizontally) very large View and, of course, I have a scroll to move it side by side. I want to put a TextView in middle, but I want it so, that when I scroll horizontally and the View moves this TextView stays in the center of the screen.
If I use android:gravity="center" or something like this, as the view is very large, I will NOT see the TextView in the center unless I am in the center of the view (Not in the beginning, and not in the end) but I need that the TextView is in the center during the whole scrolling.
I think that you can achieve that by positioning the element in the middle by setting its x-origin (with left-padding or left-margin?) to (scrollview.width/2 - textview.width/2), then add the scrollview.offset.x whenever the scrollview scrolls (add a listener to get this) so it maintains still at the relative center.
However the simplest thing may be to place a FrameLayout which contains the ScrollView and above it the TextView, which you could then center with the gravity property.
Presumably your content is all inside a ScrollView. You will need your TextView to be outside of this scroll view: you can then use the technique described in "Android overlay a view ontop of everything?" to place the TextView where you want it.

Categories

Resources