ViewPager と PagerTabStrip を利用する単純な Android プロジェクトを作成しています。ViewPager の各フラグメントは、ImageView と ProgressBar で構成されます。現在、フラグメントの ImageView は PagerTabStrip の下に配置されていません。これは、PagerTabStrip が上部にスペースを予約していると思われるからです。
理想的には、PagerTabStrip の可視性を View.GONE に変更したかのように、ImageView をストリップの下に移動させたいのですが、ストリップをオーバーレイするためにまだそこに置いておきます。
ImageView の余白を調整しようとしましたが、「FitXY」にスケーリングして XML パラメーターをいじりましたが、まだ PagerTabStrip の下に移動しません。どんな助けでも大歓迎です!これが私が以下に持っているXMLコードです:
MainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/home_screen_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.PagerTabStrip
android:id="@+id/pager_tab_strip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#000000"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:textAppearance="@style/PagerTabStripText"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
<ImageButton
android:id="@+id/fbButton"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/fb_button_left_margin"
android:layout_marginBottom="@dimen/download_button_bottom_margin"
android:background="@drawable/facebookbutton" />
<ImageButton
android:id="@+id/miscButton"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/button_margin"
android:layout_marginBottom="@dimen/download_button_bottom_margin"
android:layout_toRightOf="@+id/fbButton"
android:background="@drawable/button" />
<ImageButton
android:id="@+id/downloadButton"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/button_margin"
android:layout_marginBottom="@dimen/download_button_bottom_margin"
android:layout_toRightOf="@+id/miscButton"
android:background="@drawable/button" />
<ImageView
android:id="@+id/bottomBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:adjustViewBounds="true"
android:baselineAlignBottom="true"
android:cropToPadding="true"
android:padding="0dp"
android:scaleType="fitXY"
android:src="@drawable/bottombar" />
</RelativeLayout>
MainActivityFragment.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/imageview_description"
android:scaleType="fitXY" />
</RelativeLayout>
現在の様子のスクリーンショットは次のとおりです。
With PagerTabStrip: http://i.imgur.com/w1WaF9P
Without PagerTabStrip: http://i.imgur.com/Nr2Ny3v
2 番目の画像は、移動アニメーションを使用して PagerTabStrip を上に移動することによって実現されました。
理想的には、ImageView は左上隅の 0,0 から開始し、PagerTabStrip と重なるようにして、変換時に空白の空白がないようにします。