J'ai la disposition suivantePosition Android vue du texte avec des boutons personnalisés dans la mise en page
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
</LinearLayout>
qui donne la sortie comme
Maintenant, je dois ajouter un texte de bienvenue à la partie supérieure de l'écran
Lorsque j'ai ajouté la vue de texte comme ceci, seul le texte de bienvenue est affiché et pas de boutons et pas de défilement
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mg_userinfo" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="Welcome"
android:gravity="center" />
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
</LinearLayout>
Quand essayé ci-dessous Étalez texte d'accueil est affiché en bas des boutons, mais les boutons se sont déplacé vers le haut de l'écran
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mg_userinfo" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="Welcome"
android:gravity="center" />
</LinearLayout>
Comment puis-je avoir besoin d'ajouter un texte de bienvenue dans la section supérieure du écran avec bouton sur le centre?
L'utilisation de px n'est pas recommandée. Il ne s'échelonne pas correctement sur les appareils de densités d'écran variables. Utilisez toujours dip ou dp (les deux sont identiques). – Mudassir