如何通过LinearLayout的边界获取ImageView?

时间:2014-06-26 06:44:24

标签: android imageview android-linearlayout adt

我在Linearayout enter image description here

上有3个ImageView

但我希望得到像这样的东西:enter image description here

是否可以在线性布局中进行制作?

2 个答案:

答案 0 :(得分:0)

希望这种想法对你有帮助..

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

 <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >

   <LinearLayout 
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:layout_weight="1"
       android:background="#d67070">

    <RelativeLayout
        android:id="@+id/relative_layout_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

    </RelativeLayout>
 </LinearLayout>


 <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="#70a7d6">

    <RelativeLayout
        android:id="@+id/relative_layout_bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relative_layout_top"
         >
    </RelativeLayout>

    </LinearLayout>

</LinearLayout>

 <Button
    android:id="@+id/bt_atoz"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
   android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Button"
    android:textColor="#000000"
    android:layout_marginRight="10dp"
    android:background="#ffffff"
     />

</RelativeLayout>

答案 1 :(得分:0)

添加相关的边距。

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <!-- Place Camera image in this layout and centre in parent -->
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/camera_image" />

    <!-- Now we need a layout with green background aligned to the bottom of the parent layout -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/green" >

        <!-- Place the search icon aligned left -->
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/search_image" />

        <!-- Place the globe icon aligned right -->
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:src="@drawable/globe_image" />
    </RelativeLayout>

</RelativeLayout>