我有一个充满适配器的GridView。显示屏适用于gridView中的每个项目。但是我有一个问题,当显示主要活动时,我的gridView将在工具栏下。这是我的代码:
actyvity_main.xml:
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.americangolf.co.uk/golf-clubs/fairway-woods");
List<WebElement> brands = driver.findElements(By.cssSelector("div.refinement.brand span.refinement-count"));
int count = 0;
for (WebElement brand : brands)
{
count += Integer.parseInt(brand.getText().replaceAll("\\D+", ""));
}
System.out.println(count);
}
content_main.xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mtoy.laboiteasqueezie.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
我的GridView中的项目:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.mtoy.android.recyclerview.MainActivity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#d6d6d6">
<GridView
android:id="@+id/list1"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="150dp"
android:stretchMode="columnWidth"/>
</RelativeLayout>
我确定解决方案必须简单,但我无法弄清楚它是什么。你可以帮帮我吗?
答案 0 :(得分:2)
将此行添加到相对布局
app:layout_behavior="@string/appbar_scrolling_view_behavior"