【发布时间】:2016-11-30 15:47:37
【问题描述】:
我通过添加android:layout_marginTop="112dp" 实现了这一点,有没有其他方法可以像我们在RelativeLayout 中那样让我的ImageView 刚好低于AppBarLayout?
另外,我希望这个 ImageView 具有与 AppBarLayout 相同的阴影,因此图像将显示为 AppBarLayout 的一部分。
我希望TextView 出现在LinearLayout 中的图像下方。
主要活动 XML
<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>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="112dp"
android:orientation="horizontal">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/under_tabs_triangle"/>
</LinearLayout>
<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" />
片段主要 XML
<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"
tools:context="com.example.dexbyte.player.MainActivity$PlaceholderFragment">
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
请检查此图片:
【问题讨论】:
-
只需将
ImageViewinside 将AppBarLayout放在Toolbar下方即可。 -
这将扩展
AppBarLayout的背景,这不是我想要实现的。我附上了一张图片来显示我想要得到的结果。谢谢!
标签: android android-layout android-imageview android-coordinatorlayout android-appbarlayout