How to make second fragment overlap on first fragment while fragment transistion - android-fragments

I am working on fragment transition. When I replace the first fragment with the second fragment, it is appearing below the first fragment. I want it to move on top of first fragment. How can I do this?
fragmentTransaction.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
fragmentTransaction.replace(R.id.fragmentListView, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();

If you dont want to remove the first fragment you can use the add method instead and to place the 2nd on top of the 1st you need to reference the top most layout or use android.R.id.content
For example:
fragmentTransaction.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
fragmentTransaction.add(android.R.id.content, fragment,"MyStringIdentifierTag");
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
This will add "fragment" on top of whatever is currently visible without removing the first fragment.

Related

expand qgraphicsrectitem to cover complete scene and expand all children's in same proportion

I have created a QGraphicsView with a scene set on it with QGraphicsRectItem in it.
[fig-1]
I want that when I double click on the green rectangle marked with thick black border, the scene gets filled with only this rectangle and all its children also get expanded in same proportion.
So, when I double click , I should see something like this in complete view:
I have handled the double click event but do not know how to handle this.
Also, when I double click again, I get back to the previous state (as shown in fig-1)
As the documentation states for QGraphicsView::fitInView
Ensures that item fits tightly inside the view, scaling the view according to aspectRatioMode.
So, assuming pView is your QGraphicsViewand thisis the rectangle you want to view, call fitInView from the overloaded double click event of QGraphicsRectItem: -
pView->fitInView(this);
Based on the comments that only the rect and its children should be visible, one option to guarantee this would be, on double-click, to create a separate scene, move the rect to the new scene and switch the view to the new scene.

Position JavaFX Button in a specific location

My Question is how can i position a javafx button in a specific location.
All the time that i tried to do this simple code is resulting that the Button is only located in the Center of the screen and not on my desired location.
(I'm using StackPane)
Code:
Button button = new Button();
button.setLayoutX(x);
button.setLayoutY(y);
Thanks in advance ,
Amit.
If you want to specify the exact co-ordinates of your node, you can use a Pane instead of StackPane.
Your button, if added to a StackPane or similar layout which supports alignment, must use the translate properties to move the button. You cannot use setLayoutX() or setLayoutY() with these layouts.
Try using the following command to move the button from its initial location :
button.setTranslateX(10);
button.setTranslateY(20);

An image at a specific point in Qt

I am trying to place a .png image(firm logo) at a specific point(coordinate). I've put several buttons, one after another, and now I want the image to be displayed just below these buttons. The code below should do the trick, but the coordinates are simply not working.
//QLabel myLabel; QVBoxLayout *layout; // class members, initialized with 'this'
QPixmap pixmap("v.png");
myLabel.setPixmap(pixmap);
myLabel.setMask(pixmap.mask());
myLabel.setGeometry(QRect(312, 454, 21, 20));
layout->addWidget(&myLabel);
How should I modify the code to simply include this image, possibly at a specific coordinate (just as with QPushButton)? Note that commenting out the last line removes the image, but, even when the image is shown, the buttons cannot be clicked (and they are not part of 'layout') Please provide code that would achieve image positioning with given coordinates.
QLayout is a controller which position widgets added to it. That is why it has no any sense to set coordinates to a widget and then place it to a layout. The layout will change the widget coordinates as soon as the widget is shown.
Futhermore, if you ask how to set certain position in coordinates, you shouldn't use QLayout at all, because it will change any position you set.
QPixmap pixmap("v.png");
myLabel.setPixmap(pixmap);
myLabel.setMask(pixmap.mask());
myLabel.setFixedSize(21, 20);
myLabel.move(312, 452); //ensure that this coordinates are in you widget
myLabel.show();
You will have to either show the label or put it in a layout or make sure it was given a parent in the constructor.
myLabel.setParent(parent_window)
The setParent method might also need you to show.
myLabel.show()
or
layout.addWidget(myLabel)

How to Add custom shape button in fixed Location in QWidget

I am new to Qt. First look at the image.
http://i225.photobucket.com/albums/dd200/saravanan_comp2001/sample.png
i already created custom shape button (inherit the QWidget). now the problem is adding the buttons into another widget(Parent QWidget).
How to add this button in Fixed location and some times i need to add the buttons in overlap.
i can't use any Layout method. Please help me to fix the problem
Just create your custom shape button with the QWidget as parent and set the position using the move function.

Adding Scrollbar to JList

I'm trying to add a scrollbar to a JList (which uses a custom data model). Adding a JScrollPane actually hides the JList, instead of adding a scrollbar. When I run the code with the scrollbar, the JList is not visible, and I cannot see the data.
playlistField = new JList(playlist); // playlist is a data model
playlistField.setLocation(32, 220-36);
playlistField.setSize(350,120);
playlistField.setVisible(true);
this.add(playlistField);
listScrollPane = new JScrollPane(playlistField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Commenting out the listScrollPane = ... line makes the JList visible again and it works as expected.
What did I miss?
You need to add the scrollpane to the container, and not the list.
In your current example, by adding the list in the scrollpane, it removes the list from its original container, since a component can have only one parent.

Resources