Layout issue - Having trouble getting a view to appear below a frame layout
I am working on an app which has a paid and a free version. Both versions
display a map, which could either be Google Maps or an OSM derived map at
the moment, and I handle switching between them by loading a different map
fragment for each one. There are also two buttons that need to be
displayed at all times. On Honeycomb and later, I can handle this by
making these buttons actions in a split action bar, but for backwards
compatibility reasons, I also use a frame layout to make these buttons
appear on top of the map if the Android version is earlier than Honeycomb.
In the paid version, the map is to take up all the available screen space.
The problem is, for the free version, I need to have an ad banner at the
top, and an image linking to my company's website at the bottom, with the
map fragment in between. I am currently using a TextView for each one as
placeholders, and I can get the one at the top to appear, but never the
one at the bottom.
Here is my layout file:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MapScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/advertisement"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Advertisement placeholder"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/map_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/map_screen_button_container"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:paddingBottom="22dp"
android:gravity="center_horizontal"
android:visibility="gone">
<Button
android:id="@+id/main_button_normal"
android:onClick="callbackRequest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/menu_callback_request"
android:layout_gravity="bottom"/>
<Button
android:id="@+id/main_button_emergency"
android:onClick="emergencyCallbackRequest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/menu_emergency_request"
android:layout_gravity="bottom"/>
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/company_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Company Banner Placeholder"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
In my MapScreen activity's onCreate() method, I also do the following if
the version running is the free version:
TextView advertisement = (TextView) findViewById( R.id.advertisement );
TextView companyBanner = (TextView) findViewById( R.id.company_banner );
advertisement.setVisibility( View.VISIBLE );
companyBanner.setVisibility( View.VISIBLE );
How can I change this layout file to get both TextView objects to appear,
without ruining how the layout appears within the FrameLayout?
No comments:
Post a Comment