I need to have two TextViews displaying same number, first of which should display upper half and second lower half in order to animate those parts differently. (See images below, there's an example with '8' digit).
http://img403.imageshack.us/img403/2461/bottomtop.png
While clipping bottom is perfectly simple (setting TextView's height is just enough), the second task I find very hard. The only solution I came up with till now is to wrap TextView into some layout and set it's y position to negative - it would be OK, but I need to care about optimization because there will be many digits animated in that way simultaneously.
Do any of you know how to achieve this in more effective way?
What about overlaying the top textview OVER the bottom textview (maybe with the white spacer as well?
Related
In my Android app, I am using a RelativeLayout to custom one of my Activitys.
I have a square ImageView that I want to set precisely. In other words, I want its right border to touch the horizontal center of the layout.
Is such a thing possible without doing weird things such as centering and then marging?
It's not a perfect solution but potentially you could use:
android:layout_marginRight="xdp"
Where x is half of your screen width + half the width of your imageView?
I know it's not perfect but might help until some guru comes along
Is there a more precise way of arranging components in App Inventor than using the Vertical/Horizontal/Table Arrangement formatting elements?
I want to sparsely position about six buttons across my app screen - all different sizes.
Thank you in advance.
the short answer is: no
well, additionally you also could use empty labels as delimiter between components...
another answer is: you could use a canvas and sprite components instead of buttons. You can define sprite positions exactly at x/y coordinates of your canvas.
However keep in mind, that there are different Android devices with different screens sizes and resolutions, so normally you wouldn't set buttons exactly at x/y coordinates to avoid strange layouts for e.g. smaller or larger devices.
The bit longer answer is to use labels as spacers.
Example:
Need to center a button at the top of the screen.
Add horizontal layout with 2 label texts and button in center inside of the layout.
Click each text label and remove the actual text from right side properties menu and choose fill parent width and height.
This centers the button because the layout automatically assigns one third size to each.
Labels are the best, but longer coding answer.
I want to generate the following for my Android application.
I tried to achieve this using RelativeLayout and some drawables (empty circle, filled circle, dotted line) I created using XML , but I am not even close to it. Is it the right way to generate such views with layouts. If so, is RelativeLayout is the way to go? Or should I create a custom view for that?
why are there 4 dots between the last item and the one before it, while the other have 3 dots?
anyway, i think you can achieve those results by having a listView with custom items.
each item would be shown as a relativeLayout with 2 imageViews (one below the other) and a textView on the right of the upper one.
the upper imageView would have the large dot (filled or not), with optional dots above it, and the imageView below would stretch its size according to the textView (align to its bottom plus add some more for extra small-dots) and have tiled dots as its background.
another approach would be to have a listView of textViews and an imageView on its left, and you draw the circles according to what the listView is currently showing (even while scrolling). it's much harder, but might be more precise.
I have a problem with a specific layout in Android.
What I want to achieve is approximately this:
http://imgur.com/xiN0u
The green area should always be visible at the bottom of the screen (size can change, but only marginally)
The red area should fill the rest of the screen on top.
The cyan area (inside the red layout) is a ScrollView and can change size and should not grow bigger than the space available
What happens is this: when the list expands, depending on the layout (i have tried linear, relative, mix of those,...), either the red or green area is overlapped with the other and is not accessible any more:
http://imgur.com/b7leA
I have tried this for a day now and whatever I do, some part of the layout is always overlapped. Is there a way to tell a ScrollView to only expand to a certain height? I know maxHeight doesn't exist. I highly appreciate every input as this is driving me crazy now! Is this possible at all with Android?
I'm working on the controls for a game, and require part of the control panel (gray in the figure below) to change dynamically, either showing a single canvas (left) or 5 buttons (right). The border between the lower-row views should always be positioned at exactly the same x-position as the border between the buttons on the upper row, as shown. At the same time, all twelve upper buttons should be scaled and distributed evenly.
I've considered several approaches, but as of yet none do all of what I want:
Using two LinearLayouts, one for each row of controls: reliably aligning the borders seems to be impossible, and replacing part of the layout is difficult at best.
Using a TableLayout: again, replacing a portion of the layout is difficult.
Using a RelativeLayout: resizing and aligning buttons independently of the screen size doesn't seem possible
Any suggestions for an alternative method, or on how to make one of the above approaches work? It would also be nice if there were some way to animate the change of views, i.e. sliding in the buttons from the left over the canvas. Thanks!
Interesting, I've done this several weeks ago. What I did is to make use of this property of View object: "Visibility". So that means at a fixed position, I can set any View to display on to, not depending on any type of Layout, it can be Visibility.GONE, Visibility.VISIBLE or Visibility.INVISIBLE.
In my app, I used RelativeLayout to set relative position to the right side TextView.
Give it a try :)
In order to close this question: I have solved the problem by writing a custom layout class that places and sizes the child views without heeding the measured size of the children. Effectively this gives me the behavior of a linear layout with layout weights, but is more deterministic with border placement.
A ViewAnimator is used to switch between the Canvas and the Buttons.