この質問は何度も聞かれたようです。 少なくとも私は特にインターネット上で多くを見つけました。 しかし、答えのどれも助けられなかった、なぜか分からない。Viewpagerとナビゲーションバーの上に
私はAndroidスタジオ2.2.2で単純な空白のタブ付きアクティビティプロジェクトを作成しました 画像ビューを追加することを除いて、何も触れていません。ここ は、生成されたアクティビティのレイアウト、次のとおりです。
<?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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.company.me.navbartest.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
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"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
は、ここには何も変更しませんでした。 そしてここでは、フラグメントのレイアウトです:
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.company.me.navbartest.MainActivity$PlaceholderFragment">
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_alignParentBottom="true"
android:src="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
ここでの唯一の添加は、フラグメントの下部にImageViewのです。 コードに一切触れていませんでした。それが必要なのかどうかを知るが、念のために、それはここだしないでください:ここでは
http://pastebin.com/FuUiGpyHは結果である:
これはキットカットで撮影されたが、それはマシュマロで同じです。 小さな緑の耳を見ますか?それは私が追加したImageViewのものです。アンドロイドロゴのアイコンです。
"fitsSystemWindows"フラグのさまざまな組み合わせを試しました。失敗。私はちょうどそれがどのように動作し、使用する必要があります理解していないと思う。
フラグメントのルートオブジェクトを変更しようとしましたが、同じ結果になりました。
したがって、主な問題は、この問題を解決する方法です。このImageViewが想定されていた場所に表示されていることを確認するにはどうすればいいですか?
Gradleのスペックは以下のとおりです。私は解決策を見つけたよう
minSdkVersion 19
targetSdkVersion 25
compileSdkVersion 25
buildToolsVersion "25.0.0"
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
adjustViewBounds = "true" 'と' scaleType = "fitXY" 'を試してください –
画像ビューにボトムマージンを追加できます –
これで実際の問題は修正されません。 ImageViewは、この場合のコントロールの外観の一例にすぎません。イメージングには、それの代わりにEditTextがあります。または別のビューグループ。 –