【问题标题】:Actionbar and layout overlapping操作栏和布局重叠
【发布时间】:2015-04-02 07:49:14
【问题描述】:

我正在使用 android 中的 Actionbar。

在我的布局中,操作栏正确显示。但我的片段布局与操作栏重叠。见下图

我的布局文件在下面。

<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 下开始。是否还有其他细节需要更好地理解?

【问题讨论】:

    标签: android android-fragments android-activity android-actionbar


    【解决方案1】:

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

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

    主要的想法是,如果你正在使用

    &lt;item name="windowActionBarOverlay"&gt;true&lt;/item&gt;

    在您的操作栏样式中,您必须手动指定边距:

    <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>
    

    【讨论】:

      【解决方案2】:

      您可能正在使用没有排序元素的 RelativeLayout。您可能应该使用:

      android:layout_below="..."
      

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

      【讨论】:

      • 用我的布局文件编辑。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      相关资源
      最近更新 更多