我正在努力制作一个高度可变的半透明搜索活动 - wrap content
RecyclerView
。不幸的是,我无法适应屏幕高度并最终在底部留下奇怪的边距,如屏幕截图所示。
这是我的活动布局
<android.support.design.widget.CoordinatorLayout 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="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:theme="@style/WeatherTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/AppBarStyle.Main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:logo="@null" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/suggestionsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:visibility="gone" />
<TextView
android:id="@+id/emptyResults"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="16dp"
android:text="@string/not_found"
android:textSize="22sp"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<ProgressBar
android:id="@+id/loading"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="center"
android:background="@color/white"
android:layout_margin="14dp"
android:visibility="gone" />
</FrameLayout>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
此活动使用的主题是MainTheme.NoActionBar.Search
<style name="MainTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/theme_color_primary</item>
<item name="colorPrimaryDark">@color/theme_color_primary_dark</item>
<item name="colorAccent">@color/theme_color_accent</item>
<item name="colorControlHighlight">@color/theme_color_highlight</item>
<item name="android:textColorPrimary">@color/theme_text_color_primary</item>
<item name="android:windowBackground">@color/theme_color_background</item>
</style>
<style name="MainTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="MainTheme.NoActionBar.Search" >
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>
将会对可能导致问题的任何提示表示感谢!