2011-10-04 6 views
1

Je travaille dans android. ceci est mon xml: -Comment régler la hauteur de deux dispositions.

s'il vous plaît vérifier cela attentivement. **

<RelativeLayout 
android:layout_width="wrap_content" android:layout_height="140dip" android:id="@+id/rl_for_image_title" > 

<ImageView 
android:id="@+id/music_player_logo" 
    android:layout_height="fill_parent" 
    android:layout_width="100dip" 

    android:src="@drawable/musicplayer_logo"/> 

    </RelativeLayout> 


<RelativeLayout android:layout_width="wrap_content" android:layout_height="140dip" android:id="@+id/rl_for_texts" android:layout_toRightOf="@+id/rl_for_image_title" > 

    <TextView 
    android:id="@+id/music_player_title_name" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Title :" 
    android:layout_marginLeft="15dip"/> 


    <TextView 
    android:layout_below="@+id/music_player_title_name" 
    android:id="@+id/music_player_artist_name" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Artist : " 
    android:layout_marginLeft="15dp"/> 


    <TextView 
    android:layout_below="@+id/music_player_artist_name" 
    android:id="@+id/music_player_category" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Category : " 
    android:layout_marginLeft="15dp"/> 
    <TextView 
    android:layout_below="@+id/music_player_category" 
    android:id="@+id/music_player_date" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Date  : " 
    android:layout_marginLeft="15dp" 
    /> 
    <TextView 
    android:layout_below="@+id/music_player_date" 
    android:id="@+id/music_player_song_price" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Price : " 
    android:layout_marginLeft="15dp" 
    /> 
    </RelativeLayout> 

    <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/rl_for_seekbar" android:layout_below="@+id/rl_for_texts" android:layout_marginTop="20dip" > 

    <ImageButton 

    android:id="@+id/ButtonTestPlayPause" 
    android:layout_height="40dip" 
    android:layout_width="fill_parent" 
    android:src="@drawable/button_play"/> 
    <SeekBar 
    android:layout_below="@+id/ButtonTestPlayPause" 
    android:id="@+id/SeekBarTestPlay" 
    android:layout_height="20dip" 
    android:layout_width="match_parent" 
    android:thumb="@drawable/thumb_transparent"/> 

    <TextView 
     android:layout_below="@+id/SeekBarTestPlay" 
    android:id="@+id/SeekBarTime" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Time  :" 
    android:layout_marginLeft="15dp" 
    /> 

</RelativeLayout></RelativeLayout> 

ce qui est la sortie de ce xml ci-dessus: - enter image description here

je veux afficher au même niveau que les informations de texte. ma couche supérieure de l'image est un peu en dessous de la vue du texte comme titre, artiste. S'il vous plaît me suggérer ce que je devrais faire faire cet alignement précis. ?

+0

Ceci est un fichier XML complet. –

+0

Où est l'imageview où se trouve l'image de la note de musique? –

+0

désolé monsieur, j'ai fait une erreur. maintenant c'est bon. –

Répondre

1

Remplacer ceci pour la mise en page relative de vue de l'image:

<RelativeLayout 
    android:layout_width="100dp" android:layout_height="140dip" android:id="@+id/rl_for_image_title" > 

    <ImageView 
     android:id="@+id/music_player_logo" 
      android:layout_height="wrap_content" 
      android:layout_width="100dp" 
     android:src="@drawable/icon"/> 

</RelativeLayout> 
0

Depuis votre XML est malformé (à l'époque, je buvais mon café) ce court exemple devrait réaliser ce que vous cherchez. Approximativement. Les identifiants sont faits sur le pouce mais cela devrait être facilement réparé.

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/preview_song" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Preview Song" /> 

     <LinearLayout 
      android:id="@+id/song_information" 
      android:orientation="vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/preview_song" 
      android:layout_alignParentRight="true"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Title: TakinItOff" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Artist: Akon" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Category: Lolwtf" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Date: 2011-08-11" /> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Price: 20.0" /> 
     </LinearLayout> 

     <ImageView 
      android:id="@+id/song_album_art" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignTop="@id/song_information" 
      android:layout_alignParentLeft="true" 
      android:src="@drawable/icon" /> 
    </RelativeLayout> 
    <Button 
     android:id="@+id/btn_play" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/song_information" 
     android:text="Play" /> 

     <!-- other stuff goes here --> 
</LinearLayout> 
+0

merci jens ... –

Questions connexes