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.
Related
i have a fragment which has a stationary Image View at the top , some linear layouts to display the texts and List View at the Bottom. i want the entire screen to go up(that stationary Image View and middle part) when i scroll down in the List View.
I tried to place all layouts in a single Linear Layout and put it inside Scroll View since it has only one direct child..but that makes only the List view scroll able.
Try using CoordinatorLayout and scrolling behaviour from the design library.You can find a great tutorial here
I think that this is a simple question but I can't figure it out, I have a Scroll View with some text inside and it works perfectly, it only enables scrolling when the content doesn't fit into the screen. The thing is that I want to scroll the content no matter if it fits or not until the last line of the text reach the top of the view leaving blank space below and obviously "hiding" the content above it. I don't know if I'm explaining myself very well, thanks in advance!
Add a dummy view with height equal to the height of device's screen beneath your textview in scrollView.
In my app I have a scroll view with n number of data to be listed out. There are two buttons one is named as UP placed above scroll view and the other is DOWN placed below scroll view.
Using the UP and DOWN buttons the list of views can be scrolled.
When the scroll bar is in top the Up button will be invisible and when the scroll bar reaches the bottom the DOWN button will become invisible, I have written logic for this using the getScrollX() method.
Now my problem is when there is very few data for example 3, the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible. How to do this, please suggest me a way?
You can try and use a ViewTreeObserver to check the dimension of the View inside your ScrollView. If the dimension exceeds a certain limit (such as the screen size), the ScrollView will be scrollable. See this preview SO answer for more details. Hope that helps!
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.
I understand that View overlapping has been addressed for background images with components on top. However, what if I had the following, where the image from a button overlaps another view, outside of its container?
Example 1
View are not allowed to overlapped in LinearLayouts. It is used to arange child views in either vertical or horizontal manner. When views are bigger than its parent, it renders in the bounds of its parent and the rest is cut of.
You can stack child views on top of each other by using the framelayout. But from seeing your buttun, I think you can achieve it using a Relative layout. And telling the arrow to stay below button using layout_below attribute.