Ich versuche, eine Anwendung auf Android Studio zu machen. Ich habe 2 Knöpfe. ein Plus und ein Minus. Ich muss wissen, wie man den Text immer kleiner und größer macht, wenn ich auf einen dieser Knöpfe klicke.Text größer und kleiner machen
Das ist mein MainActivity.java:
Button Min = (Button)findViewById(R.id.Min);
Min.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView t = (TextView)findViewById(R.id.DeText);
t.setTextSize(-5);
}
});
Das ist mein .xml:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Plus"
android:layout_gravity="top|left"
android:text="+"
android:textSize="50dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Min"
android:layout_gravity="top|right"
android:text="-"
android:textSize="50dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="50dp"
android:id="@+id/DeText"
android:text="Text"/>
Ich habe auch einen Screenshot der Seite auf arbeite ich gemacht. Hoffentlich gibt mehr Informationen über mein Endprodukt:
Sie müssen diesen Code in die onCreate-Methode einfügen. –
Das hat funktioniert, vielen Dank :) –