android - Image Slider Using View Pager(With Transparent Toolbar) -


i have created image slider using view pager following tutorials.
problems wanted slider have transparent toolbar.
, when clicked on screen toolbar hide.
here's code output(i made), , output want.

  1. my activity

    public class viewinfo extends appcompatactivity{ private viewpager viewpager; private toolbar toolbar; private customswipeadapter adapter; photoviewattacher mattacher; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_view_info);     toolbar = (toolbar) findviewbyid(r.id.app_bar);     setsupportactionbar(toolbar);     viewpager = (viewpager) findviewbyid(r.id.view_pager);     adapter = new customswipeadapter(this);     viewpager.setadapter(adapter);   }   public class customswipeadapter extends pageradapter {     private int[] image_resources = {r.drawable.bsu, r.drawable.gameover2};     private context context;     private layoutinflater layoutinflater;      public customswipeadapter(context context) {         this.context = context;     }      @override     public int getcount() {         return image_resources.length;     }      @override     public boolean isviewfromobject(view view, object object) {         return (view == (linearlayout) object);     }      @override     public object instantiateitem(view container, int position) {         layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);         view item_view = layoutinflater.inflate(r.layout.swipe_layout, (viewgroup) container, false);         imageview imageview = (imageview) item_view.findviewbyid(r.id.image_view);         imageview.setpadding(5, 5, 5, 5);         imageview.setimageresource(image_resources[position]);         ((viewgroup) container).addview(item_view);          mattacher = new photoviewattacher(imageview);         mattacher.update();         return item_view;     }      @override     public void destroyitem(viewgroup container, int position, object object) {         container.removeview((linearlayout) object);     } } 

    }

2.xml(swipe_layout)

 <?xml version="1.0" encoding="utf-8"?>     <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="vertical"     android:gravity="center"     android:background="#000"     >     <imageview         android:id="@+id/image_view"         android:layout_width="match_parent"         android:layout_height="fill_parent"         android:layout_gravity="center"         android:gravity="center"         /> </linearlayout> 

3.xml(my activity's xml)

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#fff"     android:orientation="vertical"     tools:context="com.thesis.juandirection.juandirectionfinale.viewinfos.viewinfo">       <include         android:id="@id/app_bar"         layout="@layout/app_bar" />      <android.support.v4.view.viewpager         android:id="@+id/view_pager"         android:layout_width="match_parent"         android:layout_height="match_parent">      </android.support.v4.view.viewpager>  </linearlayout> 

what want effect..
transparent toolbar.
tried put listener linearlayout when user
clicked layout hide toolbar, no luck.
enter image description here when touch screen, actionbar(transparent) hide


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -