2013-05-17 2 views
1

Essayer de résoudre ce petit problème. Ci-dessous, à gauche, un exemple de la vue que j'essaie de mettre en œuvre pour une application. Sur le côté droit est la vue que je me retrouve avec. ContainerPlacez la vue sur le dessus et entre deux vues

Dans mon mock XCML j'ai décidé d'utiliser un RelativeLayout mais je ne peux pas obtenir le TextView à centrer entre les vues supérieure et inférieure.

Pour référence ici est un represenation de mon code xml:

<RelativeLayout 
    android:layout_width:"match_parent" 
    android:layout_height:"wrap_content"> 
    <ImageView 
     android:id="@+id/BlackImage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:layout_alightParentTop="true" 
     android:layout_centerHorizontal="true"/> 
    <ImageView 
     android:id="@+id/RedImage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:layout_below="@+id/BlackImage" 
     android:layout_centerHorizontal="true"/> 
    <TextView 
     android:id="@+id/TextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/BlackImage" 
     android:layout_centerHorizontal="true"/> 
</RelativeLayout> 

Toute idée de ce que je suis absent, ou comment changer pour obtenir ce que je veux?

+1

Je pense que je vais essayer un 'FrameLayout' pour cela, parce que le RelativeLayout est plutôt utilisé pour les vues alignées le long de leurs bords. De toute façon, vous pouvez essayer une marge négative ou un remplissage. – Trinimon

+0

essayer lien ci-dessous espérons qu'il vous aidera à: - duggu

Répondre

0

essayer lien ci-dessous espérons qu'il vous aidera à: -

TextView above Image view in a layout

Android listview item display text over image using array adapter

how to put text under image view

<?xml version="1.0" encoding="utf-8"?> 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" android:background="@drawable/tmp" > 


     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/uph" 
      android:layout_marginTop="-10dp"/> 

     <RelativeLayout android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top|center"> 

      <ImageView 
       android:id="@+id/imageView2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:src="@drawable/propfile" 
      /> 

      <TextView android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="text" 
       android:layout_centerInParent="true" 
      /> 
     </RelativeLayout> 
    </LinearLayout> 
+0

Je ne savais pas que je pouvais avoir plusieurs options pour 'layout_gravity'. Vous apprenez quelque chose de nouveau tous les jours! Je vais essayer, merci pour le lien! – edc598

Questions connexes