.Net程序员玩转Android开发---(10)帧布局FrameLayout

                    帧布局FrameLayout中所有的控件都在界面的左上侧,后绘制的空间会覆盖之前的控件,布局内控件以层叠方式显示,用在游戏开发方面可能多些.


              1.层叠展示

                下面这个例子中,3个textview以层叠方式显示,通过大小和颜色我们来展示下这3个控件的层叠方式
 
                     .Net程序员玩转Android开发---(10)帧布局FrameLayout_第1张图片
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  
   <TextView
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:text="游响云停工作室"
        android:gravity="center"
        android:background="#FFE4B5"
         />
    
       <TextView
        android:id="@+id/textView1"
        android:layout_width="150dp"
        android:layout_height="120dp"
        android:text="游响云停工作室"
        android:gravity="center"
        android:background="#D1EEEE"
         />
       
          <TextView
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="游响云停工作室"
        android:gravity="center"
        android:background="#EEB422"
         />
 
</FrameLayout>


                 2.商品列表示例

    .Net程序员玩转Android开发---(10)帧布局FrameLayout_第2张图片

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@raw/pad" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品名称:Ipad Air"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="10dp"
         />
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品金额:$20"

        android:layout_marginLeft="120dp"
        android:layout_marginTop="40dp"
         />
    
      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品颜色:白色"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="70dp"
         />
      
       <TextView
        android:layout_width="fill_parent"
        android:layout_height="3dp"
        android:text=""
        android:layout_marginLeft="0dp"
        android:layout_marginTop="110dp"
        android:background="#D1EEEE"
         /> 
         
        <ImageView
        android:id="@+id/imageView2"
        android:layout_width="100dp"
        android:layout_height="100dp"
           android:layout_marginTop="120dp"
        android:src="@raw/pad" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品名称:Ipad Air"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="140dp"
         />
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品金额:$20"

        android:layout_marginLeft="120dp"
        android:layout_marginTop="170dp"
         />
    
      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="商品颜色:白色"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="200dp"
         />
      
       <TextView
        android:layout_width="fill_parent"
        android:layout_height="3dp"
        android:text=""
        android:layout_marginLeft="0dp"
        android:layout_marginTop="220dp"
        android:background="#D1EEEE"
         /> 
 
</FrameLayout>



你可能感兴趣的:(移动端开发,Android开发,布局,FrameLayout,游响云停工作室)