J'ai une disposition de table avec 2 EditText dans les 2 premières lignes, et un tas de boutons fonctionnant comme un clavier personnalisé dans les autres rangées. (juste inclus seulement la première rangée de boutons dans le xml ci-dessous pour la simplicité) Les vues d'EditText sont définies comme défilement avec android:scrollbars="vertical"
. Quand j'appuie sur un bouton de mon clavier personnalisé, j'ajoute la valeur à une chaîne d'entrée, puis je règle le texte avec la méthode EditText.setText()
. Mon problème est que si le texte est trop long, il passe à la ligne suivante en redimensionnant la vue EditText complète aussi. Sinon, faire la même chose avec le clavier android par défaut fonctionne comme un charme, aller sur la ligne suivante sans redimensionner et afficher la barre de défilement sur la droite.
Voici le XMLEditText redimensionnement de l'affichage lors de l'utilisation de "setText" au lieu de l'entrée au clavier
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip">
<EditText
android:layout_weight="1"
android:scrollbars="vertical"
android:layout_height="match_parent"
android:id="@+id/input"
android:layout_span="2"
android:text="Type an expression to begin..." />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip">
<EditText
android:layout_weight="1"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:id="@+id/output"
android:layout_span="2"
android:text="Real time calculation"/>
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF0000" />
<TableRow
android:id="@+id/tableRow3"
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp" >
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_clear"
android:text="C" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_divide"
android:text="/" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_multiply"
android:text="*" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_delete"
android:text="DEL" />
</TableRow>
</TableLayout>
Quel est le problème avec la méthode setText()
? En outre, je veux ajouter une image d'arrière-plan à la fois EditText redimensionner pour s'adapter à la vue sans faire EditText redimensionner.
Toutes les suggestions seront appréciés
Ajouter image de sortie désirée –