I know I'm close but i just need a little help in inflating my layout.
I have a LinearLayout, containing a ScrollView and a HorizontalScrollView, the ScrollView contains a second LinearLayout which contains a TextView and an ImageView and the HorizontalScrollView contatins a third LinearLayout containing a TextView.
Here's the XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLinearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="@+id/scroll1"
android:layout_width="fill_parent"
android:layout_height="442dp"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/contentLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/contentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="@+id/image_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
</ScrollView>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_gravity="bottom">"
<LinearLayout
android:id="@+id/footerLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:orientation="horizontal" >
<TextView
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
The issue I am having is twofold.
The HorizontalScrollView should be at the bottom, instead it is slightly up, I am guessing due to the height dimensions on the ScrollView (This should take up all the space except for the 25dp reserved by the HorizontalScrollView.
I am having issues inflating the LinearLayouts within the ScrollViews I currently have the code:
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layoutContent; LinearLayout lin = new LinearLayout(this); TextView content = null; //Content for (int i =0; i<6; i++) { layoutContent = (LinearLayout)inflater.inflate(R.layout.details_list, null); content = (TextView)layoutContent.findViewById(R.id.contentText); content.setText("MyContent" + String.valueOf(i)); lin.addView(layoutContent); } this.setContentView(lin); //Footer lin = (LinearLayout) findViewById(R.id.footerLayout); content = null; for (int i =0; i<2; i++) { layoutContent = (LinearLayout)inflater.inflate(R.layout.details_list, null); content = (TextView)layoutContent.findViewById(R.id.footer); content.setText("Footer "+String.valueOf(i)); lin.addView(layoutContent); }
which causes me problems: As the content layout is declared as lin = new LinearLayout(this); this is not using the one from my layout file e.g. the layout looks like
MyContent0 MyContent1MyContent2MyC
onte
nt3
Footer 0 Footer 1
If i increase the number of footer items the MyContent1... appears to get pushed off the right of the screen, if I change it to
lin = (LinearLayout) findViewById(R.id.contentLayout);
I must remove the line this.setContentView(lin);
but when i do that the layout looks like:
TextView
MyContent0
--Lots of blank lines--
Footer 0 Footer 1
MyContent1
--Lots of blank lines--
MyContent2
--Lots of blank lines--
MyContent3
--Lots of blank lines--
MyContent4
--Lots of blank lines--
MyContent5
--Lots of blank lines--
If add more elements to the footer, these appear in a HorizontalScroll where Footer 1 Footer 2 is above and scrolls correctly with the rest of the content below.
Many Thanks for taking the time to read this and please let me know if you require more information.
Kind Regards