How to make recyclerview width larger than the layout width? - android-studio

I want to make the width of a recyclerView wider than the width of the layout itself so that only a part of the items of the recyclerView could be seen until the user scroll to the left.
I think an image can explain it better:
Each item of the recyclerView have 5 textViews like this:
And I want to see only 4 of them until the user scrolls to the left like this:
After scrolling, the first textView shouldn't be seen until the user scrolls to the right.
How can I accomplish that? Should I change the item layout to be larger than the screen or the recyclerView?

You must be looking for something like this.
Embed the RecyclerView (nestedScrollingEnabled=false) inside a Horizontal Scrollview
List item for Recyclerview should have the width set to wrap_content
You can checkout this project on Github

Related

Remove margins between TableRow

Hello I'm new to android studio and I'm making a calculator app. I want to position the buttons next to each other but I am unable to remove the margin between the TableRows. I set android:layout_margin="0dp" in both of my rows yet I still have a gap between them.
Here is my xml: https://pastebin.com/YuLUJg8v
EDIT: I have the height of the buttons set to match parent but for whatever reason it does still not take up the entire height of the row. It seems the problem lies with the buttons not the tablerow
I was able to solve the issue by setting the top and bottom margins of each button to -6

Vaadin horizontal layout

I have horizontal layout with 4 components : combobox, textField1 , textField2 and checkbox. Based on checkbox textField2 is displayed or not. When checkbox is set to false then textField2 is not visible. How to prevent textField1 from expanding? I would like to have fixed position for components.. if checkbox or textField2 is not displayed others remaining in page would still look the same.So prevent from expanding to remaining space for component with horizontal layout.
The simplest way would be to put the field you want to hide inside another layout that has a fixed size and remains visible. Something like this:
VerticalLayout textField2Layout = new VerticalLayout(textField2);
textField2Layout.setWidth("200px");
VerticalLayout verticalLayout = new VerticalLayout(combobox,textField1,textField2Layout,checkbox);

Adding tab icons is shrinking the size of the tab and not showing the full icon

I'm using the Java Scene Builder 2.0 to create a GUI that uses the tab pane. I've added an Imageview to each tab so I can give them icons instead of text. I set the tabs minimum width and height to 100x100 and they adjust to that size. When I add an imageview to the tab I'm making it's minimum width and height 100x100 but it shrinks the tab size and only shows a part of the icon. This happens when the imageview has a picture and when it doesn't so I don't think it's a problem with the size of the picture.
You can see from this picture the first tab from the left doesn't have an imageview and is the size I want the tabs to be. The second tab has an empty image view and the rest of the tabs have images. I would like the images to be 100x100 and fit in the tabs.
A Java Scene Builder solution is prefered but I will also gladly accept a code solution.
I solved the problem it was something simple. In the tab pane Layout settings I only changed the min height/width to 100x100 but I left the max height/width to the default which was 1.7976931348623157E308. I didn't notice that number was so small at first and I changed it to 200. Now the images display better.

How to animate TextView

I have a custom class extending TextView (I used this trick to set my custom font).
I've a ListView and its elements are represented with my custom TextView.
Sometimes happens that the text is too long to fit and it starts a new line. I want to avoid this, so i set android:singleLine=true in the XML of my element layout.
I want to know if it's possible to animate the TextView of an element of the list, so that if such element is selected, it first scrolls its text to the left, till it reaches the end of the text, then scroll back to the right till the beginning.
I tried with marquee but it looks like it can only move in one direction and it's not what i want.

Add fixed positioned Combobox inside FlowPane

I have a FlowPane which will hold many panels which are based on BorderPane.
I want to create ComboBox which will be used to filter the Panels by type. And the panels will be scrolled by ScrollPanewhen they exceed the visible area.
I want the combo box to scroll along with the FlowPane inside the ScrollPane. I want to get the result which is displayed into the picture. Can you tell me how I can get the desired result. I can very easy create BorderPanes and insert them into the FlowPane and the challenge is how to position the Combo Box and keep it always at this position.
Why don't you simply use another border pane?
Add your combobox to the top ( or additional flow pane with combobox on
it)
Add your Flowpane to the Center
Then scroll the whole border pane using the scrollpane?
What could be simpler?
Here's how you'd do it:
StackPane with 2 layers:
layer1: your ComboBox panel.
layer2: your ScrollPane with your FlowPane inside*.
*The trick is: just make your combobox panel background opaque, and some initial top inset on the flowpane so that it starts at the right place.

Resources