how can i add or remove property of coordinator layout? Such as this?
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/tab_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/navigation"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I want add or remove the layout_above property in base of value. How can i do it? Thanks
I've tried to put this code:
CoordinatorLayout layoutCoordinator = findViewById(R.id.tab_coordinator_layout);
CoordinatorLayout.LayoutParams layoutParams;
layoutParams = (CoordinatorLayout.LayoutParams) layoutCoordinatot.getLayoutParams();
layoutParams.removeRule(/* code for layout ?? */);
But it is missing the remove and add rule function why?
It is missing the addRule and removeRule functions because these function are not a part of class CoordinatorLayout.LayoutParams but of RelativeLayout.LayoutParams.
CoordinatorLayout tabCL = findViewById(R.id.tab_coordinator_layout);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tabCL.getLayoutParams();
params.removeRule(RelativeLayout.ABOVE);
tabCL.setLayoutParams(params);