Attach floating action button to element - java

I am trying to attach a floating action button (fab) to an element, as seen in this image.
I am using Shell Software's library (https://github.com/shell-software/fab). My XML consists of a RelativeLayout inside a Scrollview. Inside the relativelayout is an imageview and a textview. I want my fab to rest on the border of the imageview.
Thanks,
Geffen Avraham

Related

How I can get layout from Float Action Button android

I want get layout from Float Action Button. I did this with Snackbar like
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
Can I get a layout similar to the above method?
I want get layout FROM FAB.
FloatingActionButton extends ImageButton, which extends ImageView. So there isn't any layout to get from it. It's an ImageView so what you could eventually get is a Drawable. If you want to customise it, you'll need to play with its drawable.

How can I expand a TextView programmatically in Android?

I have a TextView for description and I want it to display 4 lines by default, show the ellipsis and have a little expansion button. When the expansion button is pressed, the TextView should be expanded to display its entire contents, and the other elements on the layout should move down.
To show the ellipsis I am using desc.setEllipsize(TextUtils.TruncateAt.END); and I am setting the maxLines programmattically in the onClick event of the expansion/collapse button.
This works to expand the amount of text visible in the TextView, but it does not enlarge the TextView itself and push the rest of the layout down so you can see everything on the screen. How can I achieve this?
Simply using desc.setMaxLines(4); does not work to expand the TextView itself/increase its height. I have also tried using an ObjectAnimator to set the maxLines for the TextView but that has the same effect.
Thanks in advance for the help!
EDIT:
Code in onClick for animating the expansion:
ObjectAnimator animation = ObjectAnimator.ofInt(
desc,
"maxLines",
25);
animation.setDuration(400);
animation.start();
desc.setEllipsize(null);

Why does my Floating Action Button only work when it is above the listview?

While trying to create a UI, I noticed that my FloatingActionButton when having the same elevation as the ListView and inside of the ListView boundaries, the button won't work. However, when I increase the elevation of the FloatingActionButton to be above the ListView everything works fine.
Does the FAB, when the elevation increases, get render on a different surfaces so that it is able to be reach? Or is there other mechanism that knows that the button is situated above the ListView so when the button is clicked, the conflicting boundaries between the ListView and the FAB is solve?

How to add toggle, switch button in WIDGET

I want to add toggle button and switch in app widget. How can I add them? I do not understand how to assign button id. Normaly we use FindViewById but what should I use in a widget?
Togglebutton a = (TB) FindViewById(R.ID.xyz)
I also added one text view widget and now I want when I click on it to update that TextView.
ToggleButton is not supported on widgets, use instead an ImageView (change image source dynamically).

Pressed Status propagation in Android

I have a layout with the following structure:
LinearLayout_1
ImageView
TextView
Linearlayout_2
ImageView
TextView
Some Views within LinearLayout_1 have padding and margins. I want to set a OnClickListener over LinearLayout_1 (for detecting clicks in the whole layout). But when its pressed I need all the items inside in pressed status. How can I do that? Thanks
Found a solution. The key is to use
android:duplicateParentState="true"
in the childs of the View where the clicks are listened

Categories