0
버튼을 사용하여 그래프와 같은 구조를 만들려고합니다.
시크 바 (seek bar)의 값에 따라이 버튼의 높이를 동적으로 수정하고 싶습니다. 이 화면에서와 같이 내가 이것을 구현할 수있어위쪽 방향으로 버튼 높이를 동적으로 수정하십시오.
1. 촬영 그러나 문제는 버튼 (자신의 기본 동작) 아래 방향으로 높이 성장입니다.
아래 그림과 같이 버튼을 위로 자라게하려면 어떻게합니까?
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"/>
활동
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);
}
나는 바보 아무것도 건가요? 어떤 도움을 주셔서 감사합니다.
버튼의 부모보기는 무엇입니까? 선형 레이아웃 인 경우 중력을 아래쪽으로 설정할 수 있습니다. – Gan
상대 레이아웃 – GAMA
'btnGraph.setGravity (Gravity.BOTTOM);'을 시도했지만 아무런 효과가 없습니다 ... – GAMA