操作栏和布局重叠问题

3

我正在使用Android中的ActionBar。

在我的布局中,ActionBar显示正常。但是我的片段布局与ActionBar重叠。请参见下面的图片。enter image description here

我的布局文件如下。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/myapp_bg"
tools:context="${relativePackage}.${activityClass}" >

<LinearLayout 
    android:id="@+id/myapp_user_info_container"
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:orientation="horizontal"
    android:background="@drawable/myapp_profile_bg"

    >
   <RelativeLayout 
       android:id="@+id/myapp_user_info_inner_container"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_marginTop="25dp"
       android:layout_marginBottom="25dp"
       >
       <com.mikhaellopez.circularimageview.CircularImageView
            android:layout_width="@dimen/myapp_circular_image_size"
            android:layout_height="@dimen/myapp_circular_image_size"
            android:layout_gravity="center"
            android:layout_marginLeft="10dp"
            android:src="@drawable/username" />

      <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="2.30"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/myapp_menu_sidebar_user_mailid"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="3dp"
            android:layout_weight="1.15"
            android:gravity="top"
            android:textColor="#ffffff"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/myapp_menu_sidebar_user_info"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="3dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="1dp"
            android:layout_weight="1.15"
            android:gravity="bottom"
            android:textColor="#ffffff" />
    </LinearLayout>
   </RelativeLayout>

</LinearLayout>

<FrameLayout
    android:id="@+id/myapp_home_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:layout_marginTop="10dp" 
    android:layout_below="@+id/myapp_user_info_container"
    android:layout_marginBottom="20dp"
    />

<include
   android:id="@+id/myapp_footer_view_id"
   android:layout_width="match_parent"
   android:layout_height="40dp"
   android:layout_alignParentBottom="true"
   layout="@layout/myapp_footer" 
   android:visibility="gone"
   />

<!-- <ProgressBar 
    android:id="@+id/myapp_progressbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    /> -->

我犯了什么错误? 我希望布局从ActionBar下方开始。是否还有其他细节需要更好地理解?

2个回答

5

我认为这可能会对你有帮助:

https://developer.android.com/training/basics/actionbar/overlaying.html

主要思想是,如果您正在使用以下内容: <item name="windowActionBarOverlay">true</item> 在您的操作栏样式中,您必须手动指定边距:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?android:attr/actionBarSize">
    ...
</RelativeLayout>

3

您可能正在使用RelativeLayout而没有对元素进行排序。您应该使用:

android:layout_below="..."

你能发一下你的布局代码吗?

使用我的布局文件进行编辑。 - Karthikeyan Ve

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接