Product Details
Download MaterialX 2.8
Get the Full Android Source Code for all the listed Layouts and more.
Buy Now for $25Layout Screenshot

package com.material.components.activity.shopping;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.core.widget.NestedScrollView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.ImageButton;
import com.material.components.R;
import com.material.components.utils.Tools;
import com.material.components.utils.ViewAnimation;
public class ShoppingProductDetails extends AppCompatActivity {
private View parent_view;
private ImageButton bt_toggle_reviews, bt_toggle_warranty, bt_toggle_description;
private View lyt_expand_reviews, lyt_expand_warranty, lyt_expand_description;
private NestedScrollView nested_scroll_view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping_product_details);
parent_view = findViewById(R.id.parent_view);
initToolbar();
initComponent();
}
private void initToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Fashion");
Tools.setSystemBarColor(this);
}
private void initComponent() {
// nested scrollview
nested_scroll_view = (NestedScrollView) findViewById(R.id.nested_scroll_view);
// section reviews
bt_toggle_reviews = (ImageButton) findViewById(R.id.bt_toggle_reviews);
lyt_expand_reviews = (View) findViewById(R.id.lyt_expand_reviews);
bt_toggle_reviews.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggleSection(view, lyt_expand_reviews);
}
});
// section warranty
bt_toggle_warranty = (ImageButton) findViewById(R.id.bt_toggle_warranty);
lyt_expand_warranty = (View) findViewById(R.id.lyt_expand_warranty);
bt_toggle_warranty.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggleSection(view, lyt_expand_warranty);
}
});
// section description
bt_toggle_description = (ImageButton) findViewById(R.id.bt_toggle_description);
lyt_expand_description = (View) findViewById(R.id.lyt_expand_description);
bt_toggle_description.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggleSection(view, lyt_expand_description);
}
});
// expand first description
toggleArrow(bt_toggle_description);
lyt_expand_description.setVisibility(View.VISIBLE);
((FloatingActionButton) findViewById(R.id.fab)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(parent_view, "Add to Cart", Snackbar.LENGTH_SHORT).show();
}
});
}
private void toggleSection(View bt, final View lyt) {
boolean show = toggleArrow(bt);
if (show) {
ViewAnimation.expand(lyt, new ViewAnimation.AnimListener() {
@Override
public void onFinish() {
Tools.nestedScrollTo(nested_scroll_view, lyt);
}
});
} else {
ViewAnimation.collapse(lyt);
}
}
public boolean toggleArrow(View view) {
if (view.getRotation() == 0) {
view.animate().setDuration(200).rotation(180);
return true;
} else {
view.animate().setDuration(200).rotation(0);
return false;
}
}
}