Android subviews, static header view

To make my explanations shorter, I made this “layout” of what I am trying to achieve. I would like to create a reusable header, footer and a general group of views that I can fill with any content. ListActivity, GridView ... etc.

alt text

I have tried several different approaches so far without any luck. My first attempt was to write three main views. RelativeLayout, which will act as a container. I used to add a header (worked), wrote a GridView (worked), and trying to attach a footer with an inclusion, it will never snap at the bottom of the screen no matter what gravity I used.

, Android. , . GridView, , . ( , "Hello GridViews" - , )

alt text

. GridView.... , , , . , LinearLayout, , GridView ( HiearchyViewer), "wrap_content", "44dip".

alt text

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
    >
        <Button
            android:layout_width="fill_parent"
            android:layout_height="44dip"
            android:text="test"
        />
    </LinearLayout>
    <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/gridview"
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent"
         android:columnWidth="112dip"
         android:numColumns="auto_fit"
         android:verticalSpacing="0dp"
         android:horizontalSpacing="0dp"
         android:stretchMode="columnWidth"
         android:gravity="center"
    />
</LinearLayout>

//, xml.

25 2010 .: , . , . ""

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include layout="@layout/titlebar" />
<ListView
    android:id="@+id/standingsListView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1.0"
    android:background="#FFF"
/>
<include layout="@layout/ad" />
</LinearLayout>
+3
1

, "Button": , , android:orientation

android android:orientation="horizontal" . , , , , LinearLayout, , layout_width="fill_parent"

: , , . ( LinearLayout)

+5

Source: https://habr.com/ru/post/1762542/


All Articles