如图所示:怎样将ImageSwitcher布满整个屏幕呢,换句话说将ImageSwitcher当作背景图显示?
    程序的运行顺序:
    首先,填充GridView(GridView里面是相册);
    其次,填充Gallery(Gallery里面是该相册的所有缩略图);
    最后,将缩略图的原图显示在ImageSwitcher上。
PS:图片的数据都是通过URL获得的。
最后对大家说声谢谢!

解决方案 »

  1.   


    <LinearLayout android:id="@+id/layout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">    <LinearLayout android:id="@+id/layout2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:orientation="horizontal">
            此处放你的ImageSwitcher
       </LinearLayout>    <LinearLayout android:id="@+id/layout3"
    android:layout_width="fill_parent"
    android:layout_height="你的Gallery的高度"
    android:orientation="horizontal">
            此处放你的Gallery
       </LinearLayout></LinearLayout>
      

  2.   

    不是这样的,我需要将ImageSwitcher控件布局整个屏幕,也就是将ImageSwitcher当作背景图片,将上面的GridView与下面的Gallery都显示在ImageSwitcher上面。
    谢谢你的答复哦!
      

  3.   

    你把原来.xml文件发上来看看。
      

  4.   


    不好意思,现在才回复你,请见谅。xml文件如下:<?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"
        android:orientation="vertical"
        android:background="@drawable/internalbg" >
        
        <RelativeLayout android:id="@+id/relative_album"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="64px"
                android:layout_marginLeft="3dp"
                android:layout_marginTop="84dp"
                android:orientation="vertical" >            <ImageView
                    android:layout_width="627px"
                    android:layout_height="18px"
                    android:src="@drawable/table_top" />            <ImageView
                    android:layout_width="629px"
                    android:layout_height="46px"
                    android:src="@drawable/table_under" />
            </LinearLayout>
            
            <HorizontalScrollView
                android:id="@+id/galleryScroll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                android:scrollbars="none" >            <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:focusable="false" >                <LinearLayout
                        android:id="@+id/linear_id"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:focusable="false"
                        android:orientation="horizontal"
                        android:paddingLeft="12dp" >                    <GridView
                            android:id="@+id/album_gallery"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:columnWidth="95dp"
                            android:focusable="false"
                            android:gravity="center"
                            android:horizontalSpacing="1.0dp"
                            android:numColumns="auto_fit"
                            android:stretchMode="spacingWidthUniform"
                            android:verticalSpacing="1.0dp" >
                        </GridView>
                    </LinearLayout>
                </FrameLayout>
            </HorizontalScrollView>
        
        </RelativeLayout>
        
        <RelativeLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            
            <FrameLayout android:id="@+id/frame_switcher"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true">

                <ImageSwitcher android:id="@+id/imageswitcher"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"/>
                <ProgressBar android:id="@+id/progress_imageswitcher"
                    style="?android:attr/progressBarStyleLarge"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:visibility="gone"
                    android:layout_gravity="center" />
                
            </FrameLayout>
        
         <Gallery android:id="@+id/images_gallery"
             android:layout_width="fill_parent"
             android:layout_height="150px"
             android:layout_alignParentLeft="true"
             android:layout_alignParentBottom="true"
             android:gravity="center_vertical"/>
            
        </RelativeLayout>
    </LinearLayout>
      

  5.   

    View相互覆盖,用:
    FrameLayout !
      

  6.   

    界面里面的控件都不是独立存在的,界面上部分我叫它是相册,相册还有相架,相架由两个ImageView组成,可以看代码。如果你说FrameLayout布局可以实现,麻烦你贴上核心的布局方式。感激不尽!
    我的想法是怎样将ImageSwither设置为背景,或者放在所有的控件背后。可能是我想错了吧,呵呵。
      

  7.   

    试试看<?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="@drawable/internalbg">
        
        <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        
            <FrameLayout android:id="@+id/frame_switcher"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true">
            
                <ImageSwitcher android:id="@+id/imageswitcher"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>
                <ProgressBar android:id="@+id/progress_imageswitcher"
                    style="?android:attr/progressBarStyleLarge"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:visibility="gone"
                    android:layout_gravity="center" />
                
            </FrameLayout>
        </LinearLayout>
        
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        
        <RelativeLayout android:id="@+id/relative_album"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="64px"
                android:layout_marginLeft="3dp"
                android:layout_marginTop="84dp"
                android:orientation="vertical" >            <ImageView
                    android:layout_width="627px"
                    android:layout_height="18px"
                    android:src="@drawable/table_top" />            <ImageView
                    android:layout_width="629px"
                    android:layout_height="46px"
                    android:src="@drawable/table_under" />
            </LinearLayout>
            
            <HorizontalScrollView
                android:id="@+id/galleryScroll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                android:scrollbars="none" >            <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:focusable="false" >                <LinearLayout
                        android:id="@+id/linear_id"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:focusable="false"
                        android:orientation="horizontal"
                        android:paddingLeft="12dp" >                    <GridView
                            android:id="@+id/album_gallery"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:columnWidth="95dp"
                            android:focusable="false"
                            android:gravity="center"
                            android:horizontalSpacing="1.0dp"
                            android:numColumns="auto_fit"
                            android:stretchMode="spacingWidthUniform"
                            android:verticalSpacing="1.0dp" >
                        </GridView>
                    </LinearLayout>
                </FrameLayout>
            </HorizontalScrollView>
        
        </RelativeLayout>
        
        <RelativeLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            
            <Gallery android:id="@+id/images_gallery"
                android:layout_width="fill_parent"
                android:layout_height="150px"
                android:layout_alignParentLeft="true"
                android:layout_alignParentBottom="true"
                android:gravity="center_vertical"/>
            
        </RelativeLayout>
    </LinearLayout>    
        
    </FrameLayout>
      

  8.   

    不行,会报错。
    你说有没有可能和程序加载部件的顺序有关系。
    LogCat提示的错误如下所示:
    08-03 17:10:48.528: E/AndroidRuntime(2517): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.photographic.ui/com.photographic.ui.BrowseAlbum}: java.lang.ClassCastException: android.widget.ProgressBar
    08-03 17:10:48.528: E/AndroidRuntime(2517): Caused by: java.lang.ClassCastException: android.widget.ProgressBar
    在你原有的基础上修改了,还是报同样的错误。程序的运行顺序:
        首先,填充GridView(GridView里面是相册);
        其次,填充Gallery(Gallery里面是该相册的所有缩略图);
        最后,将缩略图的原图显示在ImageSwitcher上。
    麻烦帮忙再看看,谢谢啦!
      

  9.   

    呵呵,解决了,心情好开心啊,谢谢你们两位的帮忙。
    心得是分析布局一定要想清楚每种布局的用途,如果代码长,先看最里面的Layout,再逐层往外看。
    最终的代码如下:<?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="@drawable/internalbg">
        
        
        <RelativeLayout android:id="@+id/relative_album"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="64px"
                android:layout_marginLeft="3dp"
                android:layout_marginTop="84dp"
                android:orientation="vertical" >            <ImageView
                    android:layout_width="627px"
                    android:layout_height="18px"
                    android:src="@drawable/table_top" />            <ImageView
                    android:layout_width="629px"
                    android:layout_height="46px"
                    android:src="@drawable/table_under" />
            </LinearLayout>
            
            <HorizontalScrollView
                android:id="@+id/galleryScroll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                android:scrollbars="none" >            <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:focusable="false" >                <LinearLayout
                        android:id="@+id/linear_id"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:focusable="false"
                        android:orientation="horizontal"
                        android:paddingLeft="12dp" >                    <GridView
                            android:id="@+id/album_gallery"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:columnWidth="95dp"
                            android:focusable="false"
                            android:gravity="center"
                            android:horizontalSpacing="1.0dp"
                            android:numColumns="auto_fit"
                            android:stretchMode="spacingWidthUniform"
                            android:verticalSpacing="1.0dp" >
                        </GridView>
                    </LinearLayout>
                </FrameLayout>
            </HorizontalScrollView>
            
            <Gallery android:id="@+id/images_gallery"
                android:layout_width="fill_parent"
                android:layout_height="150px"
                android:layout_alignParentLeft="true"
                android:layout_alignParentBottom="true"
                android:gravity="center_vertical"/>
        
        </RelativeLayout>
        
        
        <ImageSwitcher android:id="@+id/imageswitcher"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>
                <ProgressBar android:id="@+id/progress_imageswitcher"
                    style="?android:attr/progressBarStyleLarge"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:visibility="gone"
                    android:layout_gravity="center" /></FrameLayout>
      

  10.   

    测试布局是否正确的方法:新建一个Activitiy,只留个onCreate里面的setContentView(R.layout.布局文件名);