그래프를 버튼으로 그리려고 합니다
예를 들면 버튼을 생성하고
초록색이 버튼 입니다
그리고 자바단에서 값을 가져와서
사이즈(width)를 동적으로 변경 시켜주고 싶은데
===============xml====================
<Button android:id="@+id/month1"
android:layout_width="300px"
android:layout_height="45px"
android:layout_marginTop="3pt"
android:background="@drawable/graph_bar2"
/>
==================================
month1 = (Button) findViewById(R.id.month1);
month1.setText("30000");
month1.setWidth(100);
setText는 먹어도
setWidth는 안먹히네요
동적으로 변경이 안되는건가요??
ImageButton은 setWidth가 없는것 같고,,
혹시 아신다면 답변 주시면 감사하겠습니다
버튼 사이즈가 정해 져서 나와야 합니다
예를들면
1월은 100px
1월은 200px
...
10월은 50px
...
12월은 300px
이런식으로요..
알려주신 방식은 버튼 이벤트가 들어와야
바뀌지 않나요?
처음부터 제가 Button 이든 TextView이던
background로 입혀준 그림 사이즈를 정해주어야 하거든요
어차피 background로 입힌 그림은 Button사이즈가 바뀌면
거기에 맞게 뿌려주는걸로 알고 있어서
Button사이즈를 변경하고 싶었었거든요..
잘안되는데 부탁 드리겠습니다 알려주세요
늦은시간까지 죄송합니다
테스트 화면
1.Before & After 스크린 샷 입니다
2. 해당 코드
<Button android:id="@+id/button_normal"
android:text="@string/buttons_1_normal"
android:layout_width="wrap_content" <------------ 수치대신 "wrap_content"
android:layout_height="wrap_content" /> <------------ 수치대신 "wrap_content"
final Button requestInfo = (Button)findViewById(R.id.button_normal);
requestInfo.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
requestInfo.setWidth(550); <------------------ 가변값 설정
}
});
이상 입니다.