activity_main.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="match_parent">
<android.support.v7.widget.CardView android:id="@+id/dumb_card"
android:layout_margin="16dp"
tools:cardCornerRadius="4dp"
android:layout_width="match_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<SeekBar android:id="@+id/heighter"
android:layout_margin="16dp"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
<SeekBar android:id="@+id/elevator"
android:layout_margin="16dp"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
MainActivity.java
public class MainActivity extends Activity {
CardView card;
SeekBar heighter;
SeekBar elevator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//card
card = (CardView) findViewById(R.id.dumb_card);
//card height
heighter = (SeekBar) findViewById(R.id.heighter);
heighter.setMax(2500);
heighter.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
ViewGroup.LayoutParams lp = card.getLayoutParams();
lp.height = progress;
card.setLayoutParams(lp);
}
public void onStartTrackingTouch(SeekBar seekBar) {}
public void onStopTrackingTouch(SeekBar seekBar) {}
});
//card elevation
elevator = (SeekBar) findViewById(R.id.elevator);
elevator.setMax(250);
elevator.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
card.setCardElevation(progress);
}
public void onStartTrackingTouch(SeekBar seekBar) {}
public void onStopTrackingTouch(SeekBar seekBar) {}
});
}
}
AndroidManifest.xml
<application
android:label="DumbCardElevation"
android:theme="@android:style/Theme.Holo.Light" >
<activity
android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>