I'm designing a layout for some listview items and I would like to draw a vertical dotted line to separate the content from some button on the right of the row, like in the example I attached. What is the best way to do it? And moreover: is there a way to obtain it by setting up some widget's property (something like setting up a css property for a border)?
Thanks
What is the best way to do it?
Put the widgets, including a new View for your divider, into a horizontal LinearLayout. Use a ShapeDrawable as the background for the View, where the ShapeDrawable defines your desired dash pattern.
Note that most UIs that have this sort of divider use a solid line.
is there a way to obtain it by setting up some widget's property
You can try to use android:drawableLeft and similar properties instead of the LinearLayout, if one of the widgets in this row is a TextView or inherits from it.
Related
I want to know how is possible to achieve a arrow-based layout like this :
Any idea about what Layout is using this app in order to achieve that layout ? It seems like a kind of Staggered Grid Layout maybe ? Or maybe is using a library or a custom layout ? How can I achieve something similar ?
so here is how I would do something like this.
I make a bunch of custom views.
custom view #1:
PokemonView.
This is a regular Constraint Layout or CardView that contains all the items to show the pokemon, and its name, and all the other stuff.
custom view #2
EvolutionPokeminView.
this is a custom constraint layout that contains a PokemonView, and The Arrow ImageView (and TextView below), and helper methods to place the arrow in different directions.
for example:
setArrowDirection(int direction) \direction is some kind of enum for all directions (top, topLeft, topRight.. etc
another helper method is setArrorPosition,
setArrowPosition(int direction)
then you use the arrow direction method to set the correct arrow image into the arrowImageView, and you use the arrow position method to use ConstraintSet to programmatically set the correct position of the arrow in relation to the pokemon image.
after that, you prepare a few common layouts to use with different sets of data and populate them accordingly.
Things you'd need to know to make this approach work.
How to Make a Custom View in Android.
How to use ConstraintLayout effectively.
How to use ConstraintSet to programmatically edit ConstraintLayout constraints.
I have a custom semicircle Liner Layout in which I want to add colored views , but these views do not match the custom shape(or stay within the bounds of the Liner Layout)
When I assigned custom shape to the views
custom shape
when I assign MATCH_PARENT to the views
match parent
I want the views to fill the inside of the Liner Layout while retaining the shape of it, is there any way this can be done?
You can't create a custom shape to a view. VIews are always rectangular. If you mean you have a custom background, that doesn't make the view group a custom shape, or effect the layout of views within the group. If you want to do that, you need to override onLayout (and possibly onMeasure) and layout the individual children with the bounds you expect them to be in. Do not be surprised if you get some ugly or non-functional results like this- views weren't made to be circular.
In an Android app I have a background image and two buttons on it.
This is a partial screenshot:
I ask you for the best approach to click on the sinopsis button to show an overlay text, like this:
and also to click the fotos button to show an image slider, like this:
I don't want you to show me any code. I only need recommendations to know what kind of layouts or overlay views I should use to obtain the shown behaviours.
Thank you.
A simple TextView is enough. A TextView can have a background, translucent as in your case, or gradients, etc., and padding. You can fill it with Spanned Text so you could use hyperlinks, bold, colors, etc.. If you need scrolling, TextView also supports scrolling out of the box, but it'd be better to put it inside a ScrollView because the scroll will be smoother. In any case you don't need additional layouts.
You can just use a container layout (like LinearLayout. RelativeLayout, ScrollView, etc.. depending on what you want) and specify that to have a background image and then specify your drawable. You can then use TextView to display text. Don't forget though that you will have to create custom TextViews to achieve your design.
TextView can have transparent background and so, you can get the overlay effect.
I'm trying to build an Android app where I would like to display some Buttons in various places, as in the demo image attached.
The challenge here is creating the custom buttons and arranging them.
As for the custom Buttons, I guess I could achieve that using CustomViews or a simple button with a Custom Drawable as Background.
Are these the right points to start, any other ideas?
On arranging them, I have no clue how to achieve that.
As Android_Crazy and Closeratio have already said, a RelativeLayout is the most suitable option for custom placement of buttons in general. However, for the exact placement of buttons pictured in your example, a LinearLayout would work just fine.
In a LinearLayout you may place views under or above eachother (with android:orientation = "vertical", relevant for your example) or next to each other (android:orientation = "horizontal"). You can also add margin to your views to alter the horizontal position (layout_marginLeft or layout_marginRight) or the vertical position (layout_marginTop or layout_marginBottom).
As for the buttons' appearance, I always use custom background drawables, usually with a custom xml to add a different drawable for when the button is being pressed or selected.
i was requested to make in android a view that groups several items like checkboxes or text views in vertical rows, separated by transparent dividers while the background is with a certain alpha level and the edges are round.
I thought of two solutions and i hope for some feedback on good\bad or other solutions if you got'em.
just use regualr linear layout but have a single style A that uses a 9 patch as background, includes padding,margins and whatever i need to make it look like what i want. i then create another style A.up and A.down that represents the upper most and lower most items that will use a different 9-path with round corners.
inherit from linear layout, in the onMeasure and layoutChildren add to all the children some kind of space between them, i can create new attribute for it that can be customized in a style. i can override the dispatchDraw to paint the background for each view before it draws so i can paint my round borders, my only demand will be that each View added to this layout will have to be with transparent background.
So what do you think ?
Eventually i decided to use a List with customized divider.
It looks good, however a list got a very nasty bug when it comes down to items with states like buttons and clickable textViews,
you get no focus for the item and don't see the ornage bar
you don't seem to get the evnets flowing to the children of the View in the list.
I'm notsure how to resolve that one, i've seen numerous mails about it in the developres mailing list and here, most saying don't put statefull objects in a list.
So it mist not be the solution for me.
Nest thing i'll try is extending the normal layouts to have a bar in their bottom and use regualr linear layout with round corners drawable.