用RelativeLayout实现左中右三部分显示

http://mingkg21.iteye.com/blog/588214


有人问到如何实现这样的布局显示


 

实现这样的布局应该有很多种方式很多人都会了。既然有人问了,那肯定有的人还不知道怎么实现。那分享我的实现方式吧。

 

我习惯用RelativeLayout,用TableLayout应该也可以。这里我用我的习惯用法吧,用RelativeLayout。

 

这个显示分成三部分,左边(图片)、右边(播放的按钮)和中间部分(剩下的)。

 

本来想用文字描叙清楚的,限于文字描叙能力,还是看代码比较直接明了。有什么问题可以提出来讨论。

 

<?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="wrap_content">
  <ImageView
  	android:id="@+id/icon_left"
  	android:layout_width="wrap_content"
  	android:layout_height="wrap_content"
  	android:layout_alignParentLeft="true"
  	android:src="@drawable/icon"
  	/>
  <Button
  	android:id="@+id/button"
  	android:layout_width="wrap_content"
  	android:layout_height="wrap_content"
  	android:layout_alignParentRight="true"
  	android:text="button"
  	/>	
  <LinearLayout
  	android:orientation="vertical"
  	android:layout_width="fill_parent"
  	android:layout_height="wrap_content"
  	android:layout_toLeftOf="@id/button"
  	android:layout_toRightOf="@id/icon_left"
  	>
  	<TextView
  		android:layout_width="fill_parent"
  		android:layout_height="wrap_content"
  		android:text="trust you"
  		/>
  	<TextView
  		android:layout_width="fill_parent"
  		android:layout_height="wrap_content"
  		android:text="aaaaa"
  		/>
  </LinearLayout>		
</RelativeLayout>


你可能感兴趣的:(用RelativeLayout实现左中右三部分显示)