android - 如何设置两个布局的高度。?

标签 android android-layout

我在安卓系统工作。 这是我的 xml:-

请仔细检查。 **

<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>

这是上述 xml 的输出:- enter image description here

我想和文字信息同级显示。我的图像顶层比标题、艺术家等 TextView 稍低一点。请建议我应该怎么做才能使这种对齐准确。 ?

最佳答案

将此替换为 ImageView 的相对布局:

<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>

关于android - 如何设置两个布局的高度。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7649057/

相关文章:

android - 如何在 Android Studio 中添加编译器警告?

android - Sugar ORM每次单元测试都需要保存记录?

android - 是安卓:allowBackup a security risk for android applications

android - 如何在 Android Webview 上播放 rtsp 视频?

android - ToolBar 与包含 fragment 的内容(LinearLayout)重叠

android - setTranslationX/Y 和 offsetLeftAndRight/offsetTopAndBottom 之间的区别?

Android Volley 内存泄漏

java - 将 Activity 元素的排列设置为从左到右(默认)

android - drawable 中的 xml 文件,可用于所有分辨率

java - 如何在android中的水平 ScrollView 中添加多个 child