Layout-Parameter mit Android [] (Layout-Parameter mit Android), Lektion, Seite 722724
https://www.purl.org/stefan_ram/pub/layout-parameter_android (Permalink) ist die kanonische URI dieser Seite.
Stefan Ram
Android-Entwicklung

Linearbehälter-Parameter mit Android 

»WRAP_CONTENT« und »MATCH_PARENT« ohne  Gewichtung senkrecht  zur Anordnungsrichtung

Die Höhe oder Breite eines Inhaltes in einem Linearbehälter, also einem Sichtbehälter mit einer sichtbaren linearen Anordnung der Inhalte, kann durch verschiedene Angaben wie »WRAP_CONTENT« oder »MATCH_PARENT« festgelegt werden. Als Richtung  eines Linearbehälters verstehen wir hier die vertikale Richtung  bei einem vertikalen Linearbehälter  und die horizontale Richtung  bei einem horizontalen Linearbehälter.

Für jeden Inhalt eines Linearbehälters können drei Angaben gemacht werden:

Wir behandeln in diesem Abschnitt Inhalte, deren Gewichtung gleich 0 ist.

Etwas vereinfacht gesagt, minimiert  »WRAP_CONTENT« die Ausdehnung eines Inhalts, während »MATCH_PARENT« sie maximiert.

Dabei bedeutet „minimieren“, daß die Ausdehnung so klein wie möglich werden soll, ohne daß der Inhalt unsichtbar wird, und „maximieren“ bedeutet, daß die Ausdehnung so groß wie die Ausdehnung des enthaltenden Behälters – abzüglich des Ausdehnungsbedarf der vorangegangenen Inhalte – sein soll.

Die Ausdehnung eines minimierten Inhalts bezeichnen wir auch als ihre natürliche Ausdehnung, da sie sich auf naheliegende Weise durch sein Inneres ergibt.

Diese Einstellungen sind bei jeder Sichtfläche möglich, nicht nur bei einer Tastfläche, die hier als Beispiel verwendet wird.

Die hier verwendete Klasse »android.widget.LinearLayout.LayoutParams« darf nicht mit der gleichnamigen Klasse »android.view.ViewGroup.LayoutParams« verwechselt werden!

Quelle
http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html
MainActivity.java

package com.example;

public final class MainActivity extends android.app.Activity
{ int i = -1;

android.widget.Button newButton
( final android.content.Context context, final int width, final int height, final float weight )
{ final android.widget.Button button = new android.widget.Button( context );
button.setGravity( android.view.Gravity.LEFT | android.view.Gravity.TOP );
button.setText( "text" );

final android.widget.LinearLayout.LayoutParams parameters
= new android.widget.LinearLayout.LayoutParams
( /* Breite */ width, /* ist IMMER die horizontale Breite */
/* Hoehe */ height, /* ist IMMER die vertikale Hoehe */
/* Gewichtung */ weight /* gilt fuer die JEWEILIGE RICHTUNG der Anordnung */ );

button.setLayoutParams( parameters );

return button; }

android.widget.LinearLayout newLayout
( final android.content.Context context, final int orientation )
{ final android.widget.LinearLayout layout = new android.widget.LinearLayout( this );
layout.setOrientation( orientation );
return layout; }

android.widget.LinearLayout newLayout( final android.content.Context context )
{ final android.widget.LinearLayout layout =
newLayout( context, android.widget.LinearLayout.VERTICAL );
layout.addView
( newButton
( context,
/* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Gewichtung */ 0f ));
layout.addView
( newButton
( context,
/* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Gewichtung */ 0f ));
return layout; }

@java.lang.Override public void onCreate
( final android.os.Bundle bundle )
{ super.onCreate( bundle );
final android.app.Activity activity = this;
final android.content.Context context = this;
final android.widget.LinearLayout layout = newLayout( context );
enframe( layout, 0xA00FF055, 0.5 );
activity.setContentView( layout ); }

void enframe
( final android.view.View view, final int color, final double width )
{ final android.graphics.drawable.ShapeDrawable rectShapeDrawable
= new android.graphics.drawable.ShapeDrawable
( new android.graphics.drawable.shapes.RectShape() );
{ final android.graphics.Paint paint = rectShapeDrawable.getPaint();
paint.setColor( color );
paint.setStyle( android.graphics.Paint.Style.STROKE );
final android.graphics.Point size = new android.graphics.Point();
getWindowManager().getDefaultDisplay().getSize( size );
paint.setStrokeWidth( ( int )( width / 20 * java.lang.Math.sqrt
( ( double )size.x *( double )size.y ))); }
view.setBackground( rectShapeDrawable ); }}

App
 | -----------------------------------------> senkrecht zur Anordnungsrichtung
|
| .---------------------------------.
| |---------------------------------|
| | MainActivity |
| |---------------------------------|
| |.-------------------------------.|
| ||.------. || /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |||Text | || /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| ||| | || /* Gewichtung */ 0f
| ||'------' ||
| ||.-----------------------------.||
| |||Text ||| /* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT
| ||| ||| /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| ||'-----------------------------'|| /* Gewichtung */ 0f
| || ||
| || ||
| || ||
| || ||
| || ||
| |'-------------------------------'|
| '---------------------------------'
|
V Richtung der Anordnung

»WRAP_CONTENT« und »MATCH_PARENT« ohne  Gewichtung in Anordnungsrichtung

Im folgenden Quelltextfragment wird weiterhin mit »0f«, also einer Gewichtung von 0, gearbeitet.

Quelltextfragment

layout.addView
( newButton
( context,
/* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Gewichtung */ 0f ));

layout.addView
( newButton
( context,
/* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* Gewichtung */ 0f ));

layout.addView
( newButton
( context,
/* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Gewichtung */ 0f ));

Das obenstehende Quelltextfragment zeigt die Effekte einer Mischung von Sichtflächen mit »android.view.ViewGroup.LayoutParams.MATCH_PARENT« und »android.view.ViewGroup.LayoutParams.WRAP_CONTENT«.

Wird eine Fläche mit »WRAP_CONTENT« vor  der ersten Fläche mit »MATCH_PARENT« hinzugefügt, wird sie sichtbar.

Wird eine Fläche nach  der ersten Fläche mit »MATCH_PARENT« hinzugefügt, wird sie nicht sichtbar, da die erste Fläche mit »MATCH_PARENT« bereits den gesamten restlichen verfügbaren Platz aufgefüllt hat.

App
 |  .---------------------------------.
| |---------------------------------|
| | MainActivity |
| |---------------------------------|
| |.-------------------------------.|
| ||.-----------------------------.||
| |||Text ||| /* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT
| ||| ||| /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| ||'-----------------------------'|| /* Gewichtung */ 0f
| ||.------. || /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |||Text | || /* Hoehe */ android.view.ViewGroup.LayoutParams.MATCH_PARENT
| ||| | || /* Gewichtung */ 0f
| ||| | ||
| ||| | ||
| ||| | ||
| ||| | || /* unsichtbar */
| ||| | || /* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT
| ||'------' || /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |'-------------------------------'| /* Gewichtung */ 0f
| '---------------------------------'
|
V Richtung der Anordnung

Gewichtungen in Anordnungsrichtung

Wir können die Aufteilung in die Richtung der Anordnung durch eine Gewichtung beeinflussen.

Wir haben hier eine Anordnung mit »android.widget.LinearLayout.VERTICAL«, daher können wir die vertikale Aufteilung in unserem Programm durch eine Gewichtung  beeinflussen. Hierzu sollte für diese Richtung als Ausdehnung »0« eingestellt sein. Bei einem Anordnung mit »android.widget.LinearLayout.VERTICAL« sollte also die Höhe auf »0« gesetzt werden, bei einer waagerechten Anordnung sollte die Breite auf »0« gesetzt werden.

Quelltextfragment

layout.addView
( newButton
( context,
/* width */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* height */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* weight */ 0f ));

layout.addView
( newButton
( context,
/* width */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* height */ 0,
/* weight */ 1f ));

layout.addView
( newButton
( context,
/* width */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* height */ 0,
/* weight */ 2f ));

layout.addView
( newButton
( context,
/* width */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* height */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* weight */ 0f ));

Die Sichtflächen mit der Gewichtung »0f« erhalten ihre natürliche Ausdehnung entsprechend der angegebenen Höhe. Der verbleibende Platz wird anschließend unter den Flächen mit einer Gewichtung entsprechend der Gewichtungen aufgeteilt, die nicht gleich »0f« sind. (Wie im Kochbuch wenn „2 Teile Mehl und 1 Teil Wasser“ genommen werden soll.)

Damit für die Flächen mit einer Gewichtung im ersten Schritt keine unnötigen Berechnungen angestellt werden, ist es zeitsparend für diese für den ersten Schritt die konstante Höhe  0 anzugeben. Insbesondere sollte für Fläche mit einer Gewichtung nicht  »MATCH_PARENT« verwendet werden, da dies die folgende Berechnung ihrer Ausdehnung stören wird (derzeit erhalten die Flächen dann eine Ausdehnung, die dem Kehrwert  ihrer Gewichtung entspricht).

Die Ausdehnung in der zur Anordnung senkrechten Richtung (hier: der Breite) wird durch die Gewichtung nicht  beeinflußt.

App
 |
| vertikale Anordnung = vertikale Gewichtung
|
| .---------------------------------.
| |---------------------------------|
| | MainActivity |
| |---------------------------------|
| |.-------------------------------.|
| ||.------. || /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |||Text | || /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| ||| | || /* Gewichtung */ 0f
| ||'------' ||
| ||.------. --- || --- /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |||Text | ^ || ^ /* Hoehe */ 0
| ||| | 1/3 || | /* Gewichtung */ 1f
| ||| | v || |
| ||'------' --- || |
| ||.-----------------------------.|| |
| |||Text ^ ||| /* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT
| ||| | ||| Rest /* Hoehe */ 0
| ||| | ||| /* Gewichtung */ 2f
| ||| ||| |
| ||| 2/3 ||| |
| ||| ||| |
| ||| | ||| |
| ||| | ||| |
| ||| v ||| v
| ||'-----------------------------'|| ---
| ||.------. || /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| |||Text | || /* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT
| ||| | || /* Gewichtung */ 0f
| ||'------' ||
| |'-------------------------------'|
| '---------------------------------'
|
V

Veranschaulichung der Gravitation von Textflächen

Nachdem wird nun etwas über die Anordnungsparameter gelernt haben, können wir noch einmal zu der Gravitation einer Textfläche (hier an Tastflächen gezeigt) zurückkehren, da wird diese nun besser verdeutlichen können.

MainActivity.java

package com.example;

public final class MainActivity extends android.app.Activity
{ int i = -1;

android.widget.Button newButton
( final android.content.Context context,
final int gravity,
final java.lang.CharSequence text )
{ final android.widget.Button button = new android.widget.Button( context );
button.setGravity( gravity );
button.setText( text );

final android.widget.LinearLayout.LayoutParams parameters
= new android.widget.LinearLayout.LayoutParams
( /* Breite */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Hoehe */ android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
/* Gewichtung */ 1f );

button.setLayoutParams( parameters );

return button; }

android.widget.LinearLayout newLayout
( final android.content.Context context, final int orientation )
{ final android.widget.LinearLayout layout = new android.widget.LinearLayout( this );
layout.setOrientation( orientation );
return layout; }

android.widget.LinearLayout newLayout( final android.content.Context context )
{ final android.widget.LinearLayout layout = newLayout( context, android.widget.LinearLayout.VERTICAL );
layout.addView( newButton( context, android.view.Gravity.LEFT | android.view.Gravity.TOP , "LT" ) );
layout.addView( newButton( context, android.view.Gravity.LEFT | android.view.Gravity.CENTER, "LC" ) );
layout.addView( newButton( context, android.view.Gravity.LEFT | android.view.Gravity.BOTTOM, "LB" ) );
layout.addView( newButton( context, android.view.Gravity.CENTER | android.view.Gravity.TOP , "CT" ) );
layout.addView( newButton( context, android.view.Gravity.CENTER | android.view.Gravity.CENTER, "CC" ) );
layout.addView( newButton( context, android.view.Gravity.CENTER | android.view.Gravity.BOTTOM, "CB" ) );
layout.addView( newButton( context, android.view.Gravity.RIGHT | android.view.Gravity.TOP , "RT" ) );
layout.addView( newButton( context, android.view.Gravity.RIGHT | android.view.Gravity.CENTER, "RC" ) );
layout.addView( newButton( context, android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, "RB" ) );
return layout; }

@java.lang.Override public void onCreate
( final android.os.Bundle bundle )
{ super.onCreate( bundle );
final android.app.Activity activity = this;
final android.content.Context context = this;
final android.widget.LinearLayout layout = newLayout( context );
enframe( layout, 0xA00FF055, 0.5 );
activity.setContentView( layout ); }

void enframe
( final android.view.View view, final int color, final double width )
{ final android.graphics.drawable.ShapeDrawable rectShapeDrawable
= new android.graphics.drawable.ShapeDrawable
( new android.graphics.drawable.shapes.RectShape() );
{ final android.graphics.Paint paint = rectShapeDrawable.getPaint();
paint.setColor( color );
paint.setStyle( android.graphics.Paint.Style.STROKE );
final android.graphics.Point size = new android.graphics.Point();
getWindowManager().getDefaultDisplay().getSize( size );
paint.setStrokeWidth( ( int )( width / 20 * java.lang.Math.sqrt
( ( double )size.x *( double )size.y ))); }
view.setBackground( rectShapeDrawable ); }}

App
.---------------------------------.
|---------------------------------|
| MainActivity |
|---------------------------------|
|.-------------------------------.|
||.----. ||
|||LT | ||
||| | ||
||| | ||
||'----' ||
||.----. ||
||| | ||
|||LC | ||
||| | ||
||'----' ||
||.----. ||
||| | ||
||| | ||
|||LB | ||
||'----' ||
||.----. ||
||| CT | ||
||| | ||
||| | ||
||'----' ||
||.----. ||
||| | ||
||| CC | ||
||| | ||
||'----' ||
||.----. ||
||| | ||
||| | ||
||| CB | ||
||'----' ||
||.----. ||
||| RT| ||
||| | ||
||| | ||
||'----' ||
||.----. ||
||| | ||
||| RC| ||
||| | ||
||'----' ||
||.----. ||
||| | ||
||| | ||
||| RB| ||
||'----' ||
|'-------------------------------'|
'---------------------------------'

Anwendung auf das Zählerprogramm

Im folgenden Programm werden zwei Tastflächen nebeneinander  in eine horizontale Anordnung  eingefügt.

Die Höhe  wird mit »MATCH_PARENT« maximiert.

Die Breite  wird gleichmäßig zwischen beiden Tastflächen aufgeteilt, indem jeder eine Breite von »0« und ein Gewicht von »1f« zugeordnet wird.

Anschließend werden ein Textfeld und die im vorigen Schritt erzeugte horizontale Anordnung untereinander in eine vertikale Anordnung  eingefügt.

Nun wird die Breite  der Einträge mit »MATCH_PARENT« maximiert.

Die Höhe  wird gleichmäßig zwischen dem Textfeld und der horizontalen Anordnung aufgeteilt, indem jedem Eintrag eine Breite von »WRAP_CONTENT« und ein Gewicht von »1f« zugeordnet wird.

MainActivity.java

package com.example;

public class MainActivity extends android.app.Activity
{ int i = -1;

/** Einstellungen fuer einen Inhalt in einem Behaelter mit
horizontaler Anordnung (fuer die Tastflaechen).
Die Breite wird durch Gewicht 1 bestimmt.
Die Hoehe wird durch MATCH_PARENT bestimmt. */

void setHLayout( final android.view.View view )
{ final android.widget.LinearLayout.LayoutParams parameters
= new android.widget.LinearLayout.LayoutParams
( /* Breite */ 0,
/* Hoehe */ android.view.ViewGroup.LayoutParams.MATCH_PARENT, 1f );
view.setLayoutParams( parameters ); }

/** Einstellungen fuer einen Inhalt in einem Behaelter mit
vertikaler Anordnung (fuer die Tastflaechen). */

void setVLayout( final android.view.View view )
{ final android.widget.LinearLayout.LayoutParams parameters
= new android.widget.LinearLayout.LayoutParams
( /* Breite */ android.view.ViewGroup.LayoutParams.MATCH_PARENT,
/* Hoehe */ 0, 1f );
view.setLayoutParams( parameters ); }

android.widget.TextView textView;

void initTextView( final android.content.Context context )
{ MainActivity.this.textView = new android.widget.TextView( context );
MainActivity.this.textView.setGravity
( android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM );
MainActivity.this.setVLayout( MainActivity.this.textView );
/* limit height to width */
MainActivity.this.textView.setText( ++MainActivity.this.i + "" ); }

android.widget.Button increment;

void initIncrement( final android.content.Context context )
{ MainActivity.this.increment = new android.widget.Button( context );
MainActivity.this.increment.setGravity
( android.view.Gravity.LEFT | android.view.Gravity.TOP );
MainActivity.this.setHLayout( MainActivity.this.increment );
MainActivity.this.increment.setText( "increment" );
MainActivity.this.increment.setOnClickListener
( new android.view.View.OnClickListener()
{ @java.lang.Override public void onClick( final android.view.View view )
{ MainActivity.this.textView.setText( ++MainActivity.this.i + "" ); }} ); }

android.widget.Button reset;

void initReset( final android.content.Context context )
{ MainActivity.this.reset = new android.widget.Button( context );
MainActivity.this.reset.setGravity
( android.view.Gravity.LEFT | android.view.Gravity.TOP );
MainActivity.this.setHLayout( MainActivity.this.reset );
MainActivity.this.reset.setText( "reset" );
MainActivity.this.reset.setOnClickListener
( new android.view.View.OnClickListener()
{ @java.lang.Override public void onClick( final android.view.View view )
{ MainActivity.this.i = -1;
MainActivity.this.textView.setText( ++MainActivity.this.i + "" ); }} ); }

android.widget.LinearLayout hLayout;

void initHLayout( final android.content.Context context )
{ MainActivity.this.hLayout = new android.widget.LinearLayout( this );
MainActivity.this.setVLayout( MainActivity.this.hLayout );
MainActivity.this.hLayout.addView( MainActivity.this.increment );
MainActivity.this.hLayout.addView( MainActivity.this.reset ); }

android.widget.LinearLayout vLayout;

void initVLayout( final android.content.Context context )
{ MainActivity.this.vLayout = new android.widget.LinearLayout( this );
MainActivity.this.vLayout.setOrientation( android.widget.LinearLayout.VERTICAL );
MainActivity.this.vLayout.addView( MainActivity.this.textView );
MainActivity.this.vLayout.addView( MainActivity.this.hLayout ); }

void init( final android.content.Context context )
{ initTextView( context );
initIncrement( context );
initReset( context );
initHLayout( context );
initVLayout( context ); }

void enframe( final android.view.View view, final int color, final double width )
{ final android.graphics.drawable.shapes.RectShape rect
= new android.graphics.drawable.shapes.RectShape();
final android.graphics.drawable.ShapeDrawable rectShapeDrawable
= new android.graphics.drawable.ShapeDrawable( rect );
final android.graphics.Paint paint = rectShapeDrawable.getPaint();
paint.setColor( color );
paint.setStyle( android.graphics.Paint.Style.STROKE );
android.view.Display display = getWindowManager().getDefaultDisplay();
final android.graphics.Point size = new android.graphics.Point();
display.getSize( size );
paint.setStrokeWidth( ( int )( width / 20 * java.lang.Math.sqrt
( ( double )size.x *( double )size.y )));
view.setBackground( rectShapeDrawable ); }

@java.lang.Override public void onCreate
( final android.os.Bundle bundle )
{ super.onCreate( bundle );

final android.app.Activity activity = this;
final android.content.Context context = this;
init( context );
enframe( hLayout, 0xF00000FF, 1.0 );
enframe( vLayout, 0xA0005500, 0.5 );
activity.setContentView( MainActivity.this.vLayout );



}}

App

###########################################################################
/MainActivity//////////////////////////////////////////////////////////////
########################################################################### ---
########################################################################### ^
########################################################################### |
########################################################################### |
########################################################################### |
########################################################################### |
########################################################################### |
########################################################################### |
###########################################################################
########################################################################### 50 %
###########################################################################
########################################################################### |
########################################################################### |
########################################################################### |
########################################################################### |
####################################################################### # |
####################################################################### 0 # |
####################################################################### # v
########################################################################### ---
# # # ^
# increment # reset # |
# # # |
# # # |
# # # |
# # # |
# # # |
# # #
# # # 50 %
# # #
# # # |
# # # |
# # # |
# # # |
# # # |
# # # |
# # # v
########################################################################### ---

|<-------------- 50 % -------------->|<-------------- 50 % -------------->|

Man sieht, daß unsere flexible Gestaltung der Benutzeroberfläche sich sinnvoll anpaßt, wenn das Gerät gedreht wird (Strg-F12).

Übungsaufgaben

Protokollieren

Stellen Sie sich vor, daß das Programm für eine wichtige Zählung verwendet wird. Damit der Vorgang später nachvollzogen werden kann, soll jeder Tipp auf einen Taster auch noch mit Hilfe der Klasse »android.util.Log« im Logbuch aufgezeichnet werden.

Reihenfolge verändern

Verändern Sie die Reihenfolge der beiden Taster so, daß der Taster zum Inkrementieren rechts  liegt.

Anordnung verändern

Verändern Sie die Anordnung der Taster so, daß diese senkrecht übereinander  liegen und nicht mehr waagerecht nebeneinander.

Aufteilung verändern

Der dritte Layout-Parameter (oben »1f«) ist das Gewicht, welches die Aufteilung der Länge bestimmt, die nach der Zuteilung von Länge an Komponenten ohne Gewicht verleibt. Die Länge wird im Verhältnis der Gewichte aufgeteilt.

Passen Sie das Gewicht in dem obigen Programm nun so an, daß der increment-Taster doppelt so groß wird wie der reset-Taster.

Passen Sie das Gewicht in dem obigen Programm dann auch noch an, daß der Bereich mit den Tastern doppelt so groß wird wie der Bereich mit dem Textfeld.

Rückgängigmachen *

Fügen Sie eine Tastfläche “undo” zu dem Programm, so daß die Oberfläche damit möglichst schön aussieht.

Implementieren Sie dann einige oder alle der folgenden Funktionen für diesen Tastfläche:

Sie können danach auch noch eine Tastfläche “redo” hinzufügen, mit der Tippen auf “undo” rückgängig gemacht werden kann.

Dokumentation *

http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html
float weight
Indicates how much of the extra space in the LinearLayout will be allocated to the view associated with these LayoutParams.
http://developer.android.com/reference/android/widget/LinearLayout.html
public void setLayoutParams( ViewGroup.LayoutParams params )
Set the layout parameters associated with this view. These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
Parameters
params The layout parameters for this view, cannot be null
void setWeightSum(float weightSum) 
Defines the desired weights sum.

Seiteninformationen und Impressum   |   Mitteilungsformular  |   "ram@zedat.fu-berlin.de" (ohne die Anführungszeichen) ist die Netzpostadresse von Stefan Ram.   |   Eine Verbindung zur Stefan-Ram-Startseite befindet sich oben auf dieser Seite hinter dem Text "Stefan Ram".)  |   Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram. Schlüsselwörter zu dieser Seite/relevant keywords describing this page: Stefan Ram Berlin slrprd slrprd stefanramberlin spellched stefanram722724 stefan_ram:722724 Layout-Parameter mit Android Stefan Ram, Berlin, and, or, near, uni, online, slrprd, slrprdqxx, slrprddoc, slrprd722724, slrprddef722724, PbclevtugFgrsnaEnz Erklärung, Beschreibung, Info, Information, Hinweis,

Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram.
https://www.purl.org/stefan_ram/pub/layout-parameter_android