F
Freaky256
Neues Mitglied
- 0
Ich hab ein RelativeLayout zu dem ich dynamisch Buttons hinzufuegen moechte.
Das hinzufuegen funktioniert nur stimmt die Position nicht...Weis vlt jemand weshalb?
Das hinzufuegen funktioniert nur stimmt die Position nicht...Weis vlt jemand weshalb?
Code:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main">
<Button
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</ScrollView>
Code:
RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.main);
TextView tv = new TextView(this);
tv.setText("test");
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
params.addRule(RelativeLayout.BELOW, R.id.title);
tv.setLayoutParams(params);
rl.addView(tv);