Hi there,

I have a custom view that I had to write for a large scrollable image,
as the images are larger than the size of the screen.  Before, I had
tried to do it by putting the image into a ScrollView but that of
course didn't work.

The view itself is within a RelativeLayout within the activity and at
the bottom of the screen I have two buttons that are used for
navigation and at the top a TextView with a caption for the activity
(the main header is already being used here for instruction).

In my below code, I've checked the Hierachy Viewer to confirm all the
elements are loaded and in the Activity I can see the TextView,
however it overlays the ZN5ScrollView area and below the image I just
have a blank area of the size defined rather than my buttons.  For the
bottom navigation, the Hierachy Viewer is saying the absolute_y of the
bottom navigation is 480.

I'm wondering if anyone can help with my layout code here to get this
working correctly?

How it should be is:

Bottom navigation is 50px high, ZN5ScrollView is 365px above the
navigation, and the TextView takes up the rest of the area at the top:

public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setTitle("Tap Image To Return");

                /* We need to get the inflator for the bottom navigation */
                LayoutInflater inflator = (LayoutInflater)getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
                gestureScanner = new GestureDetector(this);
                res = getResources();
                bmp = BitmapFactory.decodeResource(res, 
R.drawable.zn5_overview);

                /* We need a root layout for this */
                RelativeLayout layout = new RelativeLayout(this);

                /* We now need to load the bottom navigation */
                RelativeLayout bottom_navigation = 
(RelativeLayout)inflator.inflate
(R.layout.bottom_navigation, layout);
                RelativeLayout.LayoutParams bottom_nav_params = new
RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
                bottom_nav_params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                bottom_navigation.setLayoutParams(bottom_nav_params);


                HomeButton = (ImageView) bottom_navigation.findViewById
(R.id.btn_home);
                NextButton = (ImageView) bottom_navigation.findViewById
(R.id.btn_next_session);
                HomeButton.setOnClickListener(Navigation);
                NextButton.setOnClickListener(Navigation);

                ZN5ScrollView = new ZN5ScrollView(this, bmp, IMAGE_WITDH,
IMAGE_HEIGHT);
                RelativeLayout.LayoutParams ZN5ScrollView_params = new
RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 365);
                ZN5ScrollView_params.addRule(RelativeLayout.ABOVE,
R.id.bottom_navigation);
                ZN5ScrollView.setLayoutParams(ZN5ScrollView_params);

                layout.addView(ZN5ScrollView, 1);

                TextView textView = new TextView(this);
                textView.setText("WHAT'S COOL");

                RelativeLayout.LayoutParams textView_params = new
RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
                textView_params.addRule(RelativeLayout.ABOVE, 1);

                textView.setLayoutParams(textView_params);

                layout.addView(textView, 2);

                setContentView(layout, new RelativeLayout.LayoutParams(320, 
480));
        }

Any help on this would be much appreciated!

Tane
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to