0
내 액티비티에 프로그래밍 방식으로 TextView를 삽입하려고합니다. 문제는 내가 여백 (위쪽 여백)을 설정할 수 없어 그 사이에 약간의 공간이 있다는 것입니다.안드로이드는주기 마진을 설정합니다.
<ScrollView>
<RelativeLayout_1>
<RelativeLayout_2>
<TextView/>
<EditText/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
나는 모든 불필요한 정보를 생략 :
은 XML 레이아웃의 구조는 다음과 같다.
그런 다음 내 활동에 나는 mLayout이 RelativeLayout_2에 RelativeLayout_1 및 handicap_layout을 의미mLayout = (RelativeLayout) findViewById(R.id.relative_layout);
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
relativeParams.addRule(RelativeLayout.ALIGN_LEFT, R.id.handicap_layout);
relativeParams.addRule(RelativeLayout.BELOW, R.id.handicap_layout);
TextView[] texts = new TextView[6];
for(int i=0; i<6; i++) {
texts[i] = new TextView(MyActivity.this);
texts[i].setText("Text " + (i+1));
texts[i].setTextSize(20);
relativeParams.setMargins(0, 10+(10*i), 0, 0); /* trying to increase the margin */
texts[i].setLayoutParams(relativeParams);
mLayout.addView(texts[i]);
}
을한다.
여백이 늘어나지 않고 TextView가 다른 것 위에 표시되는 것이 문제입니다.
누구나 해결책이 있습니까? 고맙습니다!