I'm trying to create graph-like structure using buttons.
I want to modify the height of these buttons dynamically based on the value of seek bar.
I'm able to implement this as shown in this screen shot 1. But the problem is buttons grows in height in downward direction (which is their default behavior).
How do I make buttons grow upward as shown below?
Xml
<Button
android:id="@+id/btnGraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/seekBar"
android:background="#99f"/>
<Button
android:id="@+id/btnGraph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/seekBar"
android:layout_toRightOf="@id/btnGraph"
android:background="#9f9"/>
Activity
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromTouch) {
tvValue.setText("Value = " + progress);
// NEGATIVE HEIGHT WONT WORK HERE...
lp = new RelativeLayout.LayoutParams(new ViewGroup.MarginLayoutParams(
50, progress * 10));
lp.setMargins(10, 300, 0, 0);
btnGraph.setLayoutParams(lp);
lp = new RelativeLayout.LayoutParams(new ViewGroup.MarginLayoutParams(
50, progress * 5));
lp.setMargins(100, 300, 0, 0);
btnGraph2.setLayoutParams(lp);
}
Am I doing anything silly? Any help appreciated.