我有以下设计,其中顶部和下方有一个CollapsingToolbarLayout,有一个RelativeLayout:
我希望RelativeLayout填充剩下的空间直到底部,所以我可以像这样集中内容:
我尝试在RelativeLayout上使用match_parent但它需要整个根布局的大小,包括CollapsingToolbarLayout:
我能做什么?这是完整布局的代码:
<?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"
tools:context=".UserActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite">
<android.support.design.widget.AppBarLayout android:id="@+id/activity_user_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout android:id="@+id/activity_user_collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar android:id="@+id/activity_user_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_collapseMode="pin">
<!-- toolbar content -->
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout android:id="@+id/activity_user_eventsalert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/calendar_remove_titlegray_48px"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="No events yet"
android:textSize="20sp"
android:textColor="@color/colorTitleGray"/>
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_gravity="bottom"
android:background="@drawable/shadow_bottom_white_to_transparent"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) android android-layout android-relativelayout android-collapsingtoolbarlayout
我的数据库安排如下:
我想从areaName获取所有值作为字符串列表或任何形式的列表,并使用它来填充Spinner.我得到的问题是它只检索最后一个值(在本例中为"纽约").这是我的实际代码:
fDatabaseRoot.child("areas").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot areaSnapshot: dataSnapshot.getChildren()) {
String areaName = areaSnapshot.child("areaName").getValue(String.class);
Spinner areaSpinner = (Spinner) findViewById(R.id.spinner);
final String[] areas = {areaName};
ArrayAdapter<String> areasAdapter = new ArrayAdapter<String>(UAdminActivity.this, android.R.layout.simple_spinner_item, areas);
areasAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
areaSpinner.setAdapter(areasAdapter);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Run Code Online (Sandbox Code Playgroud)