Moderator, Bürokraten, Checkuser-Berechtigte, developer, emailconfirmed, Oberflächenadministratoren, Oversighter, Administratoren
11.008
Bearbeitungen
(Die Seite wurde neu angelegt: „Das Layout ist aktuell so entworfen, dass beide Widgets, <code>EditText</code> und <code>Button</code>, nur so breit sind, um ihre Inhalte anzeigen zu können,…“) |
(Die Seite wurde neu angelegt: „Das funktioniert für den Button ausgezeichnet, nicht aber für das Textfeld, da der Nutzer ggf. etwas längeres eingeben wird. Es wäre schön, wenn der ungen…“) |
||
Zeile 119: | Zeile 119: | ||
Das Layout ist aktuell so entworfen, dass beide Widgets, <code>EditText</code> und <code>Button</code>, nur so breit sind, um ihre Inhalte anzeigen zu können, wie im Bild zu sehen. | Das Layout ist aktuell so entworfen, dass beide Widgets, <code>EditText</code> und <code>Button</code>, nur so breit sind, um ihre Inhalte anzeigen zu können, wie im Bild zu sehen. | ||
Das funktioniert für den Button ausgezeichnet, nicht aber für das Textfeld, da der Nutzer ggf. etwas längeres eingeben wird. Es wäre schön, wenn der ungenutzte Platz für die Breite des Textfeldes verwendet wird. Im <code>LinearLayout</code> kannst du dies mit der weight-Eigenschaft erreichen, unter Verwendung des [http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html#weight <code>android:layout_weight</code>] Attributes. | |||
The weight value is a number that specifies the amount of remaining space each view should consume, relative to the amount consumed by sibling views. This works kind of like the amount of ingredients in a drink recipe: "2 parts soda, 1 part syrup" means two-thirds of the drink is soda. For example, if you give one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view fills 2/3 of the remaining space and the second view fills the rest. If you add a third view and give it a weight of 1, then the first view (with weight of 2) now gets 1/2 the remaining space, while the remaining two each get 1/4. | The weight value is a number that specifies the amount of remaining space each view should consume, relative to the amount consumed by sibling views. This works kind of like the amount of ingredients in a drink recipe: "2 parts soda, 1 part syrup" means two-thirds of the drink is soda. For example, if you give one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view fills 2/3 of the remaining space and the second view fills the rest. If you add a third view and give it a weight of 1, then the first view (with weight of 2) now gets 1/2 the remaining space, while the remaining two each get 1/4. |
Bearbeitungen