我想制作幻灯片以全屏显示图像,但我得到的代码使用的是绝对大小,我需要将其更改为 fill_parent 但我不能。
这是代码,
公共类幻灯片扩展视图 {
public final int SLIDESHOW_DEFAULT_WIDTH = 300 ;
public final int SLIDESHOW_DEFAULT_HEIGHT = 350;
public static final int DEFAULT_CURRENT_SLIDE_INDEX_START = 0;
我想制作幻灯片以全屏显示图像,但我得到的代码使用的是绝对大小,我需要将其更改为 fill_parent 但我不能。
这是代码,
公共类幻灯片扩展视图 {
public final int SLIDESHOW_DEFAULT_WIDTH = 300 ;
public final int SLIDESHOW_DEFAULT_HEIGHT = 350;
public static final int DEFAULT_CURRENT_SLIDE_INDEX_START = 0;
请注意,可能没有必要制作自定义视图,因为一个或多个现有视图可能会执行您想要的操作。特别是,您可能想看看 ImageView 和 ImageSwitcher。
您可以在 ImageSwitcher 演示应用程序中看到这些视图的运行情况。在 Android 模拟器中,启动 API Demos 应用程序,选择 Views,然后选择ImageSwitcher。
此示例的代码可在http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.html 获得。该代码还包含在示例目录中的 Android SDK 安装中。
即使您不想使用 ImageSwitcher,您可能仍然有兴趣了解该示例如何使用 LayoutParams.MATCH_PARENT。(要支持旧版本的 Android,请将 MATCH_PARENT 替换为 FILL_PARENT。)
根据您的应用程序,仅处理 XML 中的布局可能会更简单,其中将宽度和高度设置为 match_parent(或 fill_parent)是微不足道的。