B
baileys
Neues Mitglied
- 0
Hey Leute,
habe schon gegoogelt, aber nix produktives gefunden. Wie gibt man einer TextView ein Margin?
habe schon gegoogelt, aber nix produktives gefunden. Wie gibt man einer TextView ein Margin?
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
<TextView
android:layout_width="90px"
android:layout_height="wrap_content"
android:text = "Menü"
android:textSize="16px"
android:textColor="@color/font_grey"
android:background="@color/background_white"
android:textStyle="bold"
android:shadowRadius="1.5"
android:shadowColor="#CCCCCC"
android:shadowDx="3.0"
android:shadowDy="3.0"
android:layout_marginBottom="5px"
android:layout_marginTop="5px"
android:layout_marginLeft="2px">
</TextView>
TextView tv1 = new TextView(this);
tv1.setText("text");
tv1.setGravity(Gravity.CENTER);
tv1.setWidth(20);
tv1.setTextColor(R.color.font_grey);
tv1.setPadding(2, 2, 0, 0);
LinearLayout.LayoutParams myParams = new LinearLayout.LayoutParams(1,1);
myParams.setMargins(0,0,0,1);
tv1.setLayoutParams(myParams);
tr.addView(tv1);
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params2.setMargins(20, 20, 20, 20);
TextView t2 = new TextView(this);
t2.setLayoutParams(params2);
t2.setText("Test");
t2.setBackgroundColor(Color.MAGENTA);
t2.setPadding(10, 10, 10, 10);
TextView tv1 = new TextView(this);
tv1.setText("text");
tv1.setGravity(Gravity.CENTER);
tv1.setWidth(20);
tv1.setTextColor(R.color.font_grey);
tv1.setPadding(2, 2, 0, 0);
LinearLayout.LayoutParams myParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
myParams.setMargins(0,0,0,10);
tv1.setLayoutParams(myParams);
tr.addView(tv1);
<TableRow
android:id="@+id/TableRow"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@color/background_white"
android:layout_marginTop="1px">
</TableRow>
TableLayout tl = (TableLayout)findViewById(R.id.TableWarenkorb);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
tr.setBackgroundColor(R.color.background_white);
TextView tv1 = new TextView(this);
tv1.setText("text");
tv1.setGravity(Gravity.CENTER);
tv1.setWidth(20);
tv1.setTextColor(R.color.font_grey);
tv1.setPadding(2, 2, 0, 0);
LinearLayout.LayoutParams myParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
myParams.setMargins(0,0,0,10);
tv1.setLayoutParams(myParams);
tr.addView(tv1);
TextView tv = new TextView(this);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
MarginLayoutParams mlp = new MarginLayoutParams(lp);
mlp.setMargins(0, 0, 0, 10);
//tv.setLayoutParams(mlp);
tv.setText("test");
LinearLayout ll = new LinearLayout(this);
//ll.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
ll.addView(tv, mlp);
TableRow tr = new TableRow(this);
//tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT));
tr.setBackgroundColor(Color.WHITE);
tr.addView(ll, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
TableLayout tl = new TableLayout(this);
tl.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tl.addView(tr, new TableLayout.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT));
setContentView(tl);