如图所示:怎样将ImageSwitcher布满整个屏幕呢,换句话说将ImageSwitcher当作背景图显示?
程序的运行顺序:
首先,填充GridView(GridView里面是相册);
其次,填充Gallery(Gallery里面是该相册的所有缩略图);
最后,将缩略图的原图显示在ImageSwitcher上。
PS:图片的数据都是通过URL获得的。
最后对大家说声谢谢!
程序的运行顺序:
首先,填充GridView(GridView里面是相册);
其次,填充Gallery(Gallery里面是该相册的所有缩略图);
最后,将缩略图的原图显示在ImageSwitcher上。
PS:图片的数据都是通过URL获得的。
最后对大家说声谢谢!
解决方案 »
- Android CTS Holo Testing Fails
- 急 啊:::soap2调用webservice SoapFault - faultcode: 'soapenv:Server' faultstring: 'I
- android 入门
- 高分求助GPS获取到的经纬度,绘制到google map上出错--android2.1
- 在线等待Android http下载问题(FileNotFoundException)
- PowerManager.WakeLock的问题
- android textview怎样实现文字跑马灯效果(垂直移动)
- Android 执行linux shell 语句问题
- 关于android 软件测试的问题
- 分享一个自己开发的一个APP (含源码)
- android 4.0 没有actvity就不启动服务了,求解释
- android开发怎么让一个view获得事件KeyEvent?
<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>
谢谢你的答复哦!
不好意思,现在才回复你,请见谅。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>
FrameLayout !
我的想法是怎样将ImageSwither设置为背景,或者放在所有的控件背后。可能是我想错了吧,呵呵。
<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>
你说有没有可能和程序加载部件的顺序有关系。
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上。
麻烦帮忙再看看,谢谢啦!
心得是分析布局一定要想清楚每种布局的用途,如果代码长,先看最里面的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>