【发布时间】:2016-08-17 07:43:18
【问题描述】:
我有一个带有回收器视图的片段和一个文本视图,当没有可用数据时会显示。片段托管在具有协调器布局的活动中。现在的问题是文本视图并不完全位于屏幕中心,但是当工具栏折叠时它位于中心。我希望 textview 正好在中心。如何做到这一点。
Activity的布局
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".common.ui.BaseActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<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.AppBarLayout>
<FrameLayout
android:id="@+id/home_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/navigation_view"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="left" />
FRAGMENT==><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_favourite">
</android.support.v7.widget.RecyclerView>
<TextView
android:id="@+id/empty_text_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:visibility="gone"
android:padding="@dimen/margin"
android:text="@string/empty_string_fav"
android:layout_centerInParent="true" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
android:id="@+id/progress_bar"/>
</RelativeLayout>`
【问题讨论】:
-
发布您的布局 xml 会有所帮助!
-
@LalitPoptani 发布请看一下。
标签: android android-recyclerview android-coordinatorlayout