android - Making an ImageView inside my PagerAdapter go fullscreen - How to? -
i'm testing app sort of gallery managed create using pageradapter can't make images show on fullscreen.
here screenshots: view1 on screen http://imgur.com/tvvfs2v , transition view1 view2 http://imgur.com/h6rhxfn
what want remove white borders , action bar, make image fullscreen.
here's code:
sstest.java
package com.exp.viewpagersstest1; import android.app.activity; import android.os.bundle; import android.support.v4.view.viewpager; import android.view.menu; public class sstest extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sstest); viewpager ssviewpager = (viewpager) findviewbyid(r.id.ss_view_pager); imageadapter ssadapter = new imageadapter(this); ssviewpager.setadapter(ssadapter); } @override public boolean oncreateoptionsmenu(menu menu){ // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.sstest, menu); return true; } }
imageadapter.java
package com.exp.viewpagersstest1; import android.content.context; import android.support.v4.view.pageradapter; import android.support.v4.view.viewpager; import android.view.view; import android.view.viewgroup; import android.widget.imageview; public class imageadapter extends pageradapter { context sscontext; private int[] ssimages = new int[] { r.drawable.splash1,r.drawable.splash2, r.drawable.splash3 }; imageadapter(context sscontext) { this.sscontext = sscontext; } @override public int getcount() { return ssimages.length; } @override public boolean isviewfromobject(view ssview, object ssobject) { return ssview == ((imageview) ssobject); } @override public object instantiateitem(viewgroup sscontainer, int ssposition) { imageview ssimageview = new imageview(sscontext); // int padding = sscontext.getresources().getdimensionpixelsize(0x7f040002); ssimageview.setpadding(0, 0, 0, 0); ssimageview.setscaletype(imageview.scaletype.fit_xy); ssimageview.setimageresource(ssimages[ssposition]); ((viewpager) sscontainer).addview(ssimageview, 0); return ssimageview; } @override public void destroyitem(viewgroup sscontainer, int ssposition, object ssobject) { ((viewpager) sscontainer).removeview((imageview) ssobject); } }
activity_sstest.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".sstest" > <android.support.v4.view.viewpager android:id="@+id/ss_view_pager" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:adjustviewbounds="true" /> </relativelayout>
edit:
the answer works perfectly, needed remove lines xml rid of white border:
android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin"
setting activity style noactionbar should trick. example put in manifest 1 of these:
actionbarsherlock:
<activity android:name="com.exp.viewpagersstest1.sstest" android:label="@string/app_name" android:theme="@style/theme.sherlock.noactionbar" > </activity>
native action bar:
<activity android:name="lecho.app.campus.activity.placephotoactivity" android:label="@string/app_name" android:theme="@android:style/theme.devicedefault.noactionbar.fullscreen </activity>
Comments
Post a Comment