2016-06-01 9 views
0

他のビューと重複する透明ツールバーを実行しようとしています。しかし逆に、他のビューはツールバーに重なります。オーバーラップを表示するツールバー

enter image description here

は、XMLで私が特別にオーバーラップ表示さRelativeLayoutのためmargintopを使用します。実際には、RelativeLayoutにmarginTopを使用していません。

XML

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".activity.activitys.ActivityImage"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:gravity="center"> 

     <android.support.v7.widget.AppCompatTextView 
      android:id="@+id/action_bar_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Фото"/> 
    </android.support.v7.widget.Toolbar> 

    <RelativeLayout 
     android:layout_marginTop="30dp" 
     android:id="@+id/img_slideshow_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/img_border" 
     > 
     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      /> 
     <kz.dreamwings.zhaksyadam.activity.util.CircleIndicator 
      android:id="@+id/indicator" 
      android:layout_width="fill_parent" 
      android:layout_height="55dp" 
      android:padding="3dip" 
      android:background="#99000000" 
      android:layout_above="@+id/img_name" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentBottom="true"/> 
    </RelativeLayout> 

</FrameLayout> 
+1

試み - アンドロイド:layout_below =「@ + ID /ツールバー」あなたの相対的なレイアウトで(すなわちimg_slideshow_layout)とも代わりでframeLayoutの同じ –

+0

利用のLinearLayoutからmargintop属性を削除し、すべてのものは、罰金になります –

答えて

0

変更、このようなあなたのコード:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@drawable/img_border" 
    tools:context=".activity.activitys.ActivityImage"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@android:color/transparent" 
     android:gravity="center"> 

     <android.support.v7.widget.AppCompatTextView 
      android:id="@+id/action_bar_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Фото"/> 
    </android.support.v7.widget.Toolbar> 

    <RelativeLayout 
     android:layout_marginTop="30dp" 
     android:id="@+id/img_slideshow_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     > 
     . 
     . 
     . 
0

はこれを試してみてください:相対レイアウト後にツールバーを追加し、上の余白を削除します。
.i.e:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".activity.activitys.ActivityImage"> 


    <RelativeLayout 
     android:id="@+id/img_slideshow_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/img_border" 
     > 
     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      /> 
     <kz.dreamwings.zhaksyadam.activity.util.CircleIndicator 
      android:id="@+id/indicator" 
      android:layout_width="fill_parent" 
      android:layout_height="55dp" 
      android:padding="3dip" 
      android:background="#99000000" 
      android:layout_above="@+id/img_name" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentBottom="true"/> 
    </RelativeLayout> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:gravity="center"> 

     <android.support.v7.widget.AppCompatTextView 
      android:id="@+id/action_bar_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Фото"/> 
    </android.support.v7.widget.Toolbar> 

</FrameLayout> 
1

あなたは、単一の子を保持するための基本的FrameLayoutを使用しています。あなたはFrameLayoutに子どものアライメントを管理することはできません。 レイアウトはこのようにする必要があります。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      android:gravity="center"> 

      <android.support.v7.widget.AppCompatTextView 
       android:id="@+id/action_bar_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Фото" /> 
     </android.support.v7.widget.Toolbar> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:descendantFocusability="blocksDescendants" 
     android:scrollbars="none" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <RelativeLayout 
      android:id="@+id/img_slideshow_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/img_border"> 

      <android.support.v4.view.ViewPager 
       android:id="@+id/viewpager" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 

      <kz.dreamwings.zhaksyadam.activity.util.CircleIndicator 
       android:id="@+id/indicator" 
       android:layout_width="fill_parent" 
       android:layout_height="55dp" 
       android:layout_above="@+id/img_name" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentEnd="true" 
       android:layout_alignParentRight="true" 
       android:background="#99000000" 
       android:padding="3dip" /> 
     </RelativeLayout> 

    </android.support.v4.widget.NestedScrollView> 


</android.support.design.widget.CoordinatorLayout> 
関連する問題