I am pretty new to android development and yes I have tried a lot to fix this before asking.
So I am trying to implement the FloatingActionButton (only on v21 for simplicity) and I just can't get the elevation-shadow to be rounded.
Here are the code lines I have already:
In the main activity .java (named overview):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_overview);
ImageButton fabbutton = (ImageButton) findViewById(R.id.fab);
ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
int size = getResources().getDimensionPixelSize(R.dimen.round_button_diameter);
outline.setOval(0, 0, size, size);
}
};
fabbutton.setOutlineProvider(viewOutlineProvider);
main activity .xml:
<ImageButton
android:id="@+id/fab"
android:layout_width="@dimen/round_button_diameter"
android:layout_height="@dimen/round_button_diameter"
android:layout_gravity="end|bottom"
android:background="@drawable/oval_ripple"
android:src="@android:drawable/ic_input_add"
android:tint="@android:color/white"
android:elevation="@dimen/elevation_low"
android:stateListAnimator="@anim/button_elevation"
android:layout_alignBottom="@+id/expandableListView"
android:layout_alignEnd="@+id/expandableListView"
android:layout_marginRight="@dimen/add_button_margin"
android:layout_marginBottom="@dimen/add_button_margin"
android:contentDescription="@string/fab"
android:cropToPadding="false" />
dimens.xml
<dimen name="round_button_diameter">56dp</dimen>
<dimen name="add_button_margin">16dp</dimen>
<dimen name="elevation_low">8dp</dimen>
<dimen name="elevation_high">14dp</dimen>
oval_ripple.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="oval">
<solid android:color="#fff1d744"/>
</shape>
</item>
button_elevation.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<objectAnimator
android:propertyName="translationZ"
android:duration="@android:integer/config_shortAnimTime"
android:valueFrom="8dp"
android:valueTo="14dp"
android:valueType="floatType"/>
</item>
<item>
<objectAnimator
android:propertyName="translationZ"
android:duration="@android:integer/config_shortAnimTime"
android:valueFrom="14dp"
android:valueTo="8dp"
android:valueType="floatType"/>
</item>
I hope I haven't forget any important code-part and sorry for the long post but I am pretty helpless. If it would help I also could upload the AndroidStudio project file.
Greetings from Germany and thanks for the answers. :)