如何在android for profile pic中显示重叠布局

时间:2014-10-01 13:28:33

标签: android android-layout android-ui

大家好我想在滑动菜单中显示用户个人资料信息。

enter image description here

所以我尝试了这段代码

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

<RelativeLayout
    android:id="@+id/layoutTop"
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:background="@drawable/sliding_menu_background" >
</RelativeLayout>

<RelativeLayout
    android:id="@+id/layoutBottom"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_alignParentBottom="true"
    android:layout_below="@id/layoutTop"
    android:background="#f47e55" >
</RelativeLayout>

<RelativeLayout
    android:id="@+id/info"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_above="@id/layoutBottom"
    android:layout_marginBottom="-40dp"
    android:layout_marginLeft="20dp"
    android:adjustViewBounds="true" >

    <com.itrecruter.View.CircularImageView
        android:id="@+id/circular_image_view"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:scaleType="centerInside"
        android:src="@drawable/default_profil_photo" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="1dp"
        android:layout_toRightOf="@+id/circular_image_view"
        android:singleLine="true"
        android:text="XYZ PQR"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:singleLine="true"
        android:text="Android / iOS Developer"
        android:textColor="@android:color/white"
        android:textStyle="bold" />
</RelativeLayout>

但是对于nexus 5和nexus 4,它看起来像这样: -

enter image description here

如何解决这种布局问题? 任何帮助表示赞赏 谢谢

1 个答案:

答案 0 :(得分:0)

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@android:color/black"
    android:layout_height="match_parent">

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

       <View
           android:id="@+id/layoutTop"
           android:layout_width="match_parent"
           android:layout_height="120dp"
           android:background="@android:color/black" />

    <View
        android:id="@+id/layoutBottom"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_alignParentBottom="true"
        android:layout_below="@id/layoutTop"
        android:background="#f47e55" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/info"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginTop="40dp"
    android:layout_marginBottom="-40dp"
    android:layout_marginLeft="20dp"
    android:adjustViewBounds="true">

    <com.itrecruter.View.CircularImageView
        android:id="@+id/circular_image_view"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:scaleType="centerInside"
        android:src="@drawable/default_profil_photo" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="1dp"
        android:layout_toRightOf="@+id/circular_image_view"
        android:singleLine="true"
        android:text="XYZ PQR"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:singleLine="true"
        android:text="Android / iOS Developer"
        android:textColor="@android:color/white"
        android:textStyle="bold" />
</RelativeLayout>


</FrameLayout>

试试这个