Snackbar coming below the software buttons in Marshmallow - android-6.0-marshmallow

My Snackbar coming below the software buttons in Marshmallow:
I have tried changing the view, but it is not helping.

Usually Snackbar requires the CoordinaterLayout or window decor's content which are considered as parent layout for Snackbar. Previously, it was not getting any parent layout so it directly considered WindowManager layout as parent layout. Using CoordinaterLayout as parent layout it, solved the problem.
The sample code for CoordinaterLayout is as follows:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:nimbuzz="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
</android.support.design.widget.CoordinatorLayout>

Related

xamarin.forms master detail menu page from both sides

I have a master detail page that displays from the left. But Id also like this exact feature coming from the other side. so TWO side drawer menus.
It is possible to show the page on the other side by doing:
<MasterDetailPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Khaled.Views.MainMenu"
Title="Title"
FlowDirection="RightToLeft"
x:Class="Khaled.Views.MainMenu.Page_MainMenu">
But this doesnt copy the page, it just shows it on the other side. I want TWO on each side (with the option to swipe it open)
Anyone got any idea on how to do that?
Like Mina Fawzy said, MasterDetailPage is obsolete as of version 5.0.0. Please use FlyoutPage instead.
You would be better to use the single side. When you set the VisualElement.FlowDirection property to RTL OR LTR, it would change the direction in which the UI elements on the page are scanned by the eye.
Left to Right:
Right to Left:
That's why we could not set both sides at the same time. But we could change the FlowDirection property at runtime through we do not suggest to do that. Changing this value at runtime causes an expensive layout process that will affect performance.
The way used to change the FlowDirection to RightToLeft.
Android:
Xaml:
<FlyoutPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App1.FlyoutPage1"
FlowDirection="LeftToRight"
xmlns:pages="clr-namespace:App1">
......
</FlyoutPage>
AndroidManifest.xml:
<application android:label="App1.Android" android:theme="#style/MainTheme" android:supportsRtl="true"></application>
iOS:
For ios, refer to the link below. https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/right-to-left#ios
you can create icons in the top right and top left (hamburger menu)
and then control them by code.
FlowDirection --> this controls the direction of the menu
IsPresented --> flag to open or close menu by code
when you want to present the right menu
FlowDirection = "RightToLeft";
IsPresented= true;
for the left
FlowDirection = "LeftToRight";
IsPresented= true;
Recommendation
MasterDetails are deprecated use FlyoutPage
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.masterdetailpage?view=xamarin-forms

How to create an overflow menu (not on the toolbar) - Xamarin.Forms

I understand how to create a ToolbarItem and set it's Order equal to Secondary which will give me an overflow menu like so:
But I'm not sure how I could implement such a menu in other parts of my application. For instance in the app I'm currently working on, I've removed the toolbar and created my own meaning there is no way to set the ToolbarItems property. I can add a ImageButton for the 3 dots overflow menu icon but I cannot get it to display a menu like the out of the box implementation does.
I'd also like to use this in other parts of my app (not just on the toolbar) such as on some sort of CardView.
Has anyone dealt with this problem before?
You can use Absolute layout to achieve this:
<AbsoluteLayout>
<StackLayout RowSpacing="0" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
<!--Main Content of the screen-->
</StackLayout>
<BoxView Color="Gray" AbsoluteLayout.LayoutBounds="1,0,250,250" AbsoluteLayout.LayoutFlags="PositionProportional" />
</AbsoluteLayout>
In the above code I have used a BoxView of Gray background for that menu toolbar to just show a demo, you can implement your view and set the width and height accordingly and make that view visible on click of icon which you will add on the toolbar.
Output:
This can be easily achieved using AbsoluteLayout in Xamarin.Forms
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/absolute-layout
https://xamgirl.com/absolutelayout-in-xamarin-made-simple/

JavaFX : Adapt component height to its children height?

I'm trying to develop a desktop app using javaFX (2.2), and I'm experiencing some difficulties to really get it to behave like I would like it to. Being a new user of the framework, I might not be using it as it should be...
What I want is a kind of dashbord, with several JavaFX or custom controls inside a ScrollPane. I currently have several views that look like this :
<AnchorPane id="userContent" xmlns:fx="http://javafx.com/fxml" fx:controller="squalp.view.OrgViewController">
<children>
<ScrollPane fx:id="scrollPane" styleClass="transparent" hbarPolicy="NEVER" vbarPolicy="AS_NEEDED" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox fx:id="vBox" styleClass="transparent" alignment="TOP_LEFT" focusTraversable="true">
<children>
<Label text="Label" />
<Button fx:id="bTest" text="Test" onAction="#test"/>
<TreeView fx:id="orgTree" focusTraversable="true" />
</children>
</VBox>
</content>
</ScrollPane>
</children>
</AnchorPane>
As long as I keep using simple controls, no problem, items are correctly placed one after another in th VBox.
But when using TreeViews or TableViews, I can only get my controls to have fixed height, meaning extra space on the bottom, or new scroll bars, in addition to the main one. What I would like to achieve is to adapt my controls to their current content height.
Qt's QML, for exemple, has a childrenHeight property, and it's kind of what I'm looking for. I figure this content height must be calculated somehow, since components scrollbars do adapt to the content.
I had to use a workaround for tableviews :
table.setPrefHeight(list.size() * rowHeight + headerHeight);
but I couldn't find a way to track displayed items on a treeview.
Has anyone an idea of what I could be doing to handle this issue ? Or I am really not using the framework as I should ?
Thanks in advance.
EDIT : Visual description of the problem :
Case 1
Here my treeview's height is set to a default value. There are not enough items to fill the treeview : if I want to put another component below, there'll be a gap; if my scene is not big enough, the ScrollPane's scrollbar appears, even though all the displayable content is visible.
Case 2
If if expand my treeview's items, there are now too many of them. They are not all visible at once, and the treeview's scrollbar appears, even though I already have a scrollable view with the scrollpane.
What I would like is my TreeView to adapt to its content height (reduced height if items are collapsed, bigger height if they are expanded), in order to be able to put several components one after another and to scroll through them all using the ScrollPane's scrollbar.
Since the TreeView component has itself a scrollbar, its visible content's height must be calculated at some point (since scrollbars basically use ratios based on contentHeight/componentHeight). This information doesn't seem to be available in the public API, but I wonder if, developping a custom class that expands TreeView, there could be a way to bind my component to its "visible height".
There maybe a proper way to achieve your goal, but I can suggest the approach similar to tableview's.
orgTree.prefHeightProperty().bind(orgTree.impl_treeItemCountProperty()
.multiply(treeRowHeight)); // treeRowHeight maybe 24.
Note that this is only a workaround where the deprecated and internal use-only method is used, which maybe removed in future releases.
I was looking for way to make TreeView auto-resize to fit its content, e.g. when a node is expanded or collapsed. Here's what I eventually do. Note the Platform.runLater() is required, thus simple property binding would not work here. Also note the cellHeight is the height of a tree node. It's beyond the scope of the question here how to get that.
treeView.expandedItemCountProperty().addListener((obs, oldV, newV) -> {
Platform.runLater(() -> {
treeView.setPrefHeight(newV.intValue() * cellHeight);
});
});
You can use the binding property of the view to the childs height property. By this, whenever the height of the Parent changes, childs height will automatically change ! This is not automatic height adaption, like you want, but a forced adaption, which will help you !
Width property is also available
Basically this is a snippet that will help you :
pane.heightProperty().addListener(new ChangeListener<Number>() {
#Override
public void changed(ObservableValue<? extends Number> arg0,
Number oldValue, Number newValue) {
table.setPrefHeight(newValue - 200);/*The difference of height between
parent and child to be maintained*/
}
});

Customizing container for Android UI elements

I'm trying to style my android application and new to styling UI elements. I'd like to create a custom UI container which looks like the following:
I.e. the container draws the arrow shape around the content. I'm also hoping to have the feature such the the arrow end of the container will scale nicely according to the height of the content (so possibly using vector graphics), but this is less crucial.
After spending most of the day playing around with the UI with no success, I thought I'd ask for help here. I've tried playing around with custom UI elements, using the drawable right property, the background property and trying to construct it out of other elements.
Does anyone know the best way to do this?
Thanks
I dont think you need to draw the arrow shaped container yourself. You could use a transparent png and set it as a background for the container. e.g your xml should roughly look like this:
<LinearLayout
android:id="#+id/container_layout"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/arrow_shaped_transparent_png">
<!-- The rest of the stuff goes in here e.g a textview in your case -->
</LinearLayout>

Icon padding in actionbarsherlock

I use actionbarsherlock in my app and the icon on it isn't displayed as I want. How can I change paddings of the icon? I want the image to reach top bottom and left.
I had the same problem as you and I found the answer here
Just make an XML drawable and put it in the resource folder "drawable" (without any density or other configuration).
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="#drawable/my_logo"
android:right="10dp"/>
</layer-list>
The last step is to set this new drawable as logo in your manifest (or
on the Actionbar object in your activity)

Resources