dans ma demande, Je souhaite afficher un TextView en haut de l'écran avec la largeur de l'écran. Suivant veulent afficher une vue graphique ci-dessous sur TextView. Suivant Afficher une vue texte ci-dessous cette vue graphique.
J'ai utilisé après le code XML. Dans mon code TextView ne pouvait pas afficher en bas de la screen. P> p> Quelle modification je veux mettre dans ce code pour obtenir mon résultat ??? ??? p> p>
4 Réponses :
Définir la hauteur linearlayout
Si je définis Remplir le parent sur TOUT la mise en page signifie Top TextView uniquement Affichage uniquement.
SET Android: Layout_height = "Fill_Parent" Propriété pour toutes les afficher Attendez-vous à TextView .... P>
Si je définis comme si cela signifie top TextView uniquement affiché.
U avait utilisé relativenelayout? Je suis sûr que ça fonctionnera bien .. n plz Modifier votre code correctement BCZ Certains code ne sont pas visibles
J'ai utilisé la mise en page relative. Maintenant, mon top TextView ne pourrait pas afficher.
au lieu d'utiliser linearlayout en tant que mise en page parent, utilisez une mise en page relative. Essayez d'utiliser le code suivant
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/relative01" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:background="#FF8A11" android:padding="8dip" android:id="@+id/textView01" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/textView01" > <com.game.viewdot.ViewDot android:id="@+id/DrawView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Another Text View" android:background="#FF8A11" android:padding="8dip" /> </LinearLayout> </RelativeLayout>
Mais être un développeur, je veux savoir que est-il possible de le faire par la mise en page linéaire?
@Prateekbhardwaj Oui, vous pouvez faire la même chose en utilisant également la mise en page linéaire.
Essayez ceci
Juste curieux, pourquoi avez-vous besoin android: layout_gravity = "bas" code>?
Pourquoi n'utilisez-vous pas
relativenelayout code>? À nouveau éditer la mise en page afin qu'elle puisse voir correctement