1

これActivityはフルスクリーンで実行されます。には立面図がないためKitkatViewPagerは の上にありToolbarます。

これが私のレイアウトです:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/PhotoPager_Layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:theme="@style/ThemeOverlay.AppCompat"
    >
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"
        android:background="@color/md_dark_appbar"
        android:windowActionBarOverlay="true"
        />

    <com.horaapps.leafpic.Views.HackyViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/photos_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

これは次のようになります。 スクリーンショット

この問題を解決する方法について何かアドバイスはありますか?

4

3 に答える 3

2

RelativeLayout の項目は z オーダーです。デフォルトの順序は次のとおりです。以前のアイテムは後のアイテムの後ろにあります。ツールバーは RelativeLayout の最初にあるため、他のビューの背後にあります。

3 つの解決策があります。どれでも使用できます。

  1. RelativeLayout でビューを並べ替えます: toolbat を末尾に移動します:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/PhotoPager_Layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:theme="@style/ThemeOverlay.AppCompat"
    >
    
        <com.horaapps.leafpic.Views.HackyViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/photos_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar"
            android:background="@color/md_dark_appbar"
            />
    </RelativeLayout>   
    
  2. onCreate() のどこかで toolbar.bringToFront() を呼び出します (このレイアウトをアクティビティに使用する場合)。例:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        setContentView(R.layout.layout_activity);// your resource name here
    
        View toolbar = findViewById(R.id.toolbar);
        toolbar.bringToFront();
    
        ....
    }
    
  3. onCreate のどこかでツールバー ビューの親に対して ViewGroup::bringChildToFront を呼び出します。アクティビティの onCreate でこのレイアウトを使用する場合、コードは次のようになります。

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_activity);// your resource name here
        RelativeLayout root = findViewById(R.id.PhotoPager_Layout);
        View toolbar = findViewById(R.id.toolbar);
        root.bringChildToFront(toolbar);
    
        ....
    }
    
于 2016-06-23T19:24:37.797 に答える
0

問題をよりよく理解するために、HackyViewPager カスタム ビューのコードを提供することをお勧めします。しかし、私の推測では、そこには異なる OS バージョンが下部のソフトボタン (HOME、BACK、MENU) を数えているとは考えていないということです。Lollipop 以降、ソフト ボタンは画面の一部になりましたが、以前のバージョンでは画面の外にありました。お役に立てれば。

于 2016-06-23T19:23:20.620 に答える