I have an internal custom view set up and that part seems to be working perfectly - what i'm wondering is ... is it possible to limit the height of the custom view similar to something along the lines of in Swing where you have a Scroll Pane in the Center of a Border Layout and another Panel in the South of the Border Layout.
I have 4 text views in the north, then my custom scroll view in the center, and i'd like to have the app remain static at the bottom
I tried doing the following 3 in the xml: (pseudo xml - most deleted for readability)
1.
<LinearLayout ...> // vertical
<TextView ...></TextView>
<LinearLayout ...> // horizontal
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
</LinearLayout>
<ScrollView...>
<LinearLayout ...>
<view class="blah.blah.blah.CustomView" ...>
</view>
</LinearLayout>
</ScrollView>
<RelativeLayout ...>
<com.google.ads.AdView ... />
</RelativeLayout>
</LinearLayout>
2.
<LinearLayout ...> // vertical
<TextView ...></TextView>
<LinearLayout ...> // horizontal
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
</LinearLayout>
<ScrollView...>
<LinearLayout ...>
<view class="blah.blah.blah.CustomView" ...>
</view>
<RelativeLayout ...>
<com.google.ads.AdView ... /&g开发者_如何学Ct;
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
3.
<LinearLayout ...> // vertical
<TextView ...></TextView>
<LinearLayout ...> // horizontal
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
<TextView ...></TextView>
</LinearLayout>
<ScrollView...>
<LinearLayout ...>
<view class="blah.blah.blah.CustomView" ...>
</view>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout ...>
<com.google.ads.AdView .../>
</LinearLayout>
any help as to what i can do to make this work would be greatly appreciated
If I'm understanding correctly, try #1 using weight=1 and a 0dip height on your ScrollView
:
android:layout_height="0dip"
android:layout_weight="1"
android:fillViewport="true"
Your ScrollView will automatically grow to fill up the remainder screen, pushing the ad (RelativeLayout
) to the bottom (on any screen size/orientation).
Although its not your exact layout, here's a full sample from one of my layouts which should be similar.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip">
<TextView
android:id="@+id/edit_name_label"
android:paddingTop="10dip"
android:textSize="14sp"
android:text="Name"
android:singleLine="true"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/edit_name_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:saveEnabled="true"
android:capitalize="sentences" />
<TextView
android:id="@+id/edit_type_label"
android:textSize="14sp"
android:text="Type"
android:singleLine="true"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip" />
<EditText
android:id="@+id/edit_type_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:saveEnabled="true"
android:capitalize="sentences" />
<TextView
android:id="@+id/edit_description_label"
android:textSize="14sp"
android:text="Description"
android:singleLine="true"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip" />
<EditText
android:id="@+id/edit_description_edittext"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top"
android:scrollbars="vertical"
android:saveEnabled="true"
android:capitalize="sentences" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="3dip"
android:paddingRight="3dip"
android:paddingLeft="3dip"
android:background="@drawable/bottom_bar_background">
<Button
android:id="@+id/edit_cancelbutton"
android:text="Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:layout_alignParentLeft="true" />
<Button
android:id="@+id/edit_savebutton"
android:text="Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
精彩评论