• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Changing of GridView while adding to LinearLayout

I have such an xml file:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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=".ProgramsFragment">

<!-- TODO: Update blank fragment layout -->


<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:columnWidth="200dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@String/your_articles"
android:gravity="center_horizontal"
android:textStyle="bold"/>
</LinearLayout>
</ScrollView>
</FrameLayout>

My aim was to make a scrollable layout, which contains GridView and TextView. TextView shoulde me below the GridView. When I run my program GridView size become small and I don't know why. Probably there's nothing in textview what can change GridView size in a such way (as I think). But maybe I am wrong, as when I delete TextView, LinearLayout and ScrollView everything works correctly. What's the matter? Here's a screen of my problem:
K8bm7.png


I add to GridView by this way:

private final String[] programs = {"Slim body for a four weeks", "Exercises for woman at home", "Effective exercises for biceps at home",
"Program of effective trainings twice a week", "Training on a horizontal bar for increasing muscle mass",
"Fitness program for woman: trainings at home at in gym"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1,programs);
GridView gridView = view.findViewById(R.id.gridView);
gridView.setAdapter(adapter);
 
Back
Top Bottom