开发者

Set a Width and Height to Fill Parent Android SlideShow

i want to make a SlideShow to show the image in fu开发者_开发百科ll screen but the code i got was using a absolute size, i need to change it to fill_parent but i can't.

here is the code,

public class SlideShow extends View {

    public final int SLIDESHOW_DEFAULT_WIDTH = 300 ;
    public final int SLIDESHOW_DEFAULT_HEIGHT = 350;
    public static final int DEFAULT_CURRENT_SLIDE_INDEX_START = 0;


Note that it might not be necessary to make a custom View, as one or more of the existing Views may do what you want. In particular, you might want to take a look at ImageView and ImageSwitcher.

You can see these views in action in the ImageSwitcher demo application. In an Android emulator, launch the API Demos app, select Views, and then ImageSwitcher.

The code for this example is available at http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.html. The code is also included in Android SDK installations in the samples directory.

Even if you don't want to use an ImageSwitcher, you may still be interested to see how the example uses LayoutParams.MATCH_PARENT. (To support older versions of Android, replace MATCH_PARENT with FILL_PARENT.)

Depending on your app, it might be even simpler to just handle the layout in XML, where it's trivial to set widths and heights to match_parent (or fill_parent).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜