I am finding it impossible to produce my desired layout in android studio.
I have a very simple gimmick drawing app and I'm trying to add a colour palette as a gridView. The palette is too big to not overlap the canvas, so I'd like to show it while the colour button is pressed so you can swipe to your desired colour.
Positioning the palette gridview is proving difficult. I would like it overlapping the canvas, above and horizontally centred with the 'pencil' colour selection button. I've tried two methods:
Having the gridview exist in the top-level relative layout, so it can easily overlap the canvas. This is as per the screenshot. However, I can't position it relative to the button here because the button is in a different layout.
Having the relative layout containing button and palette contained in the control view, as shown in the tree diagram. However, the palette won't draw outside its parent layout, and the relativeview can't overlap the canvas because it's in the linear layout for controls which goes beneath the canvas.
It seems like such a trivial thing - is it really impossible? Should I abandon all pretense of linear layouts and place everything in one relative layout?
Tree diagram
Related
I m trying to making a bottom slide view and when it pops up i want to get the entire layout from behind blurred.
I couldn't do it. I read that many people recommends the Library "Blurry" but it is not working.
Blurry.with(context).radius(20).sampling(2).onto((ViewGroup)linear);
linear is my LinearLayout that is behind my Constraint. I want to blur that linear
I'm creating a simple custom view. My view inherits from AppCompatImageButton with the goal of drawing some simple geometric shapes for my custom button and animating them.
If my XML view contains:
android:background="#color/transparent"
My view draws correctly inside a vertical LinearLayout, even though the android:background seems to otherwise do nothing. However, if I leave out android:background, the top and bottom displays an additional unwanted gap between the custom views.
The documentation says these two are "Related":
View.setBackgroundResource(int resid)
android:background
I've tried calling setBackgroundResource(R.color.transparent) in my Java initialization code, thinking this would do the same thing as XML android:background, but the unwanted padding won't go away. Here's a screenshot that shows the view without the android:background.
With android:background, the image fills the entire height not leaving the gap at the top and bottom.
How can I get my custom view to fill the entire drawing area without forcing an artificial android:background into the XML? The solution will also need to work if the programmer creates the custom view in Java without XML.
Thx.
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.
There are three views in my layout (button textview button) and the buttons visibility may change( Invisible/Gone, whatever makes implementing this possible).
The image attached explains my problem, please have a look.
What I'm trying to do is implement the logic which the iPhone navigation bar follows, but i cant seem to get it working.
What i have tried :
Linear layouts, with all permutations of weights & gravity
relative layout with assigning parentCenterHorizontal to the middle text view, parentLeft and parentRight to the left and right buttons - By doing this the views overlap each other, when extended. rather than making them shift. If i use the the toLeftOf or toRightOf attributes, it overrides the parentCenter/parentLeft/parentRight tags, which makes this approach useless.
The following screenshot illustrates a simple example of what I have now:
What I'd like to achieve, is that the selected (blue) view not be clipped at the boundary of the red container. My first try was clipChildren="false", which causes the blue view to expand outside of its borders, filling the the red area. I just want to see the portion overlaying the green area.
I think you'll have to float the blue on top of both the red and green. You can't have a child outside of its parent ViewGroup (AFAIK). You'll need to redesign your layout.
Getting what you want should be pretty easy, though. I don't use the graphical designer, so would need XML.
FrameLayout with LinearLayout inside to show the Red/Green, then another Linear or Relative after the first LinearyLayout (inside the FrameLayout). With LinearLayout, I'd align right, and give the blue element some padding.
It may be possible to do this all with RelativeLayout, but I tend to stay away from it.
Essentially what you're looking for is overlapping views. This can be done with a FrameLayout. For information on how to do this, please checkout this example.