List of usage examples for android.widget RelativeLayout CENTER_IN_PARENT
int CENTER_IN_PARENT
To view the source code for android.widget RelativeLayout CENTER_IN_PARENT.
Click Source Link
From source file:io.imoji.sdk.grid.ui.ResultView.java
public ResultView(Context context, @ResultViewSize int viewSize) { super(context); this.context = context; this.viewSize = viewSize; int resultWidth = getDimension(0); int resultHeight = getDimension(1); setLayoutParams(new StaggeredGridLayoutManager.LayoutParams(resultWidth, resultHeight)); placeholder = new ImageView(context); int placeholderSide = getDimension(4); RelativeLayout.LayoutParams placeholderParams = new LayoutParams(placeholderSide, placeholderSide); placeholderParams.addRule(RelativeLayout.CENTER_IN_PARENT); placeholder.setLayoutParams(placeholderParams); addView(placeholder);/*from w w w.j a v a 2s.c o m*/ container = new RelativeLayout(context); addView(container, new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); final Animation pressedAnimation = AnimationUtils.loadAnimation(context, R.anim.search_result_pressed); final Animation releasedAnimation = AnimationUtils.loadAnimation(context, R.anim.search_result_released); imageView = new GifImageView(context) { @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (searchResult != null && !searchResult.isCategory()) { imageView.startAnimation(pressedAnimation); } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: if (searchResult != null && !searchResult.isCategory()) { imageView.startAnimation(releasedAnimation); } break; } return super.onTouchEvent(event); } }; RelativeLayout.LayoutParams imageParams = new LayoutParams(resultWidth, resultWidth); imageParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageView.setLayoutParams(imageParams); container.addView(imageView); textView = new TextView(context); int titleHeight = getDimension(2); RelativeLayout.LayoutParams titleParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, titleHeight); titleParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); textView.setLayoutParams(titleParams); textView.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Montserrat-Light.otf")); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getDimension(3)); //TODO // FIXME: 5/2/16 textView.setTextColor(getResources().getColor(R.color.search_result_category_title)); textView.setGravity(Gravity.CENTER); container.addView(textView); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { listener.onTap(searchResult); } }); }
From source file:com.qs.qswlw.view.Mypager.UltraViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { int realPosition = position; //TODO/*from ww w .j a v a 2 s .co m*/ if (enableLoop && adapter.getCount() != 0) { realPosition = position % adapter.getCount(); } Object item = adapter.instantiateItem(container, realPosition); //TODO View childView = null; if (item instanceof View) childView = (View) item; // if (item instanceof RecyclerView.ViewHolder) // childView = ((RecyclerView.ViewHolder) item).itemView; ViewPager viewPager = (ViewPager) container; int childCount = viewPager.getChildCount(); for (int i = 0; i < childCount; i++) { View child = viewPager.getChildAt(i); if (isViewFromObject(child, item)) { viewArray.put(realPosition, child); break; } } if (isEnableMultiScr()) { if (scrWidth == 0) { scrWidth = container.getResources().getDisplayMetrics().widthPixels; } RelativeLayout relativeLayout = new RelativeLayout(container.getContext()); if (childView.getLayoutParams() != null) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( (int) (scrWidth * multiScrRatio), ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); childView.setLayoutParams(layoutParams); } container.removeView(childView); relativeLayout.addView(childView); container.addView(relativeLayout); return relativeLayout; } return item; }
From source file:com.tmall.ultraviewpager.UltraViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { int realPosition = position; //TODO/*from w w w. j a va 2 s . c o m*/ if (enableLoop && adapter.getCount() != 0) { realPosition = position % adapter.getCount(); } Object item = adapter.instantiateItem(container, realPosition); //TODO View childView = null; if (item instanceof View) childView = (View) item; if (item instanceof RecyclerView.ViewHolder) childView = ((RecyclerView.ViewHolder) item).itemView; ViewPager viewPager = (ViewPager) container; int childCount = viewPager.getChildCount(); for (int i = 0; i < childCount; i++) { View child = viewPager.getChildAt(i); if (isViewFromObject(child, item)) { viewArray.put(realPosition, child); break; } } if (isEnableMultiScr()) { if (scrWidth == 0) { scrWidth = container.getResources().getDisplayMetrics().widthPixels; } RelativeLayout relativeLayout = new RelativeLayout(container.getContext()); if (childView.getLayoutParams() != null) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( (int) (scrWidth * multiScrRatio), ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); childView.setLayoutParams(layoutParams); } container.removeView(childView); relativeLayout.addView(childView); container.addView(relativeLayout); return relativeLayout; } return item; }
From source file:com.mllrsohn.videodialog.VideoDialogPlugin.java
private void playVideo(JSONObject params, final CallbackContext callbackContext) throws JSONException { loopVideo = params.optBoolean("loop", true); path = params.optString("url"); uri = Uri.parse(path);//from w ww . j av a 2 s .c om if (path.contains(ASSETS)) { try { String filepath = path.replace(ASSETS, ""); String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename); if (!fp.exists()) { this.copy(filepath, filename); } uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename); } catch (IOException e) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION)); } } // Create dialog in new thread cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Set Basic Dialog dialog = new Dialog((Context) cordova.getActivity(), android.R.style.Theme_NoTitleBar_Fullscreen); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); // Layout View RelativeLayout main = new RelativeLayout((Context) cordova.getActivity()); main.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // Video View mVideoView = new VideoView((Context) cordova.getActivity()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.setVideoPath(uri.toString()); mVideoView.start(); main.addView(mVideoView); dialog.setContentView(main); dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN); dialog.show(); // Close on touch mVideoView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "stopped")); dialog.dismiss(); return true; } }); // Set Looping mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(loopVideo); } }); // On Completion mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaplayer) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, "Done")); dialog.dismiss(); } }); } }); }
From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);/*from w ww . jav a2 s .c o m*/ return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewStandardThumbnail = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewStandardThumbnail.setLayoutParams(imageViewParams); imageViewStandardThumbnail.setVisibility(View.INVISIBLE); imageViewStandardThumbnail.setBackgroundResource(R.drawable.border); imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewStandardThumbnail); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); // Center a view in relative layout RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading videos, display videos if they have been saved before. String videosFilePath = ""; if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page); } else { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page); } boolean videosFileExists = FileUtil.fileExist(videosFilePath); if (videosFileExists) { loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler, VideoListFragmentActivity.videoSource, progressBar, playlistID, page); loadPlaylistVideosFromLocalTask.execute(); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1 if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Playlist, playlistID, pageToken, page); } else { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Search, queryTerm, pageToken, page); } loadVideosTask.execute(); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:com.gokuai.yunkuandroidsdk.compat.v2.UrlTouchImageView.java
@SuppressWarnings("deprecation") protected void init() { mImageView = new TouchImageView(mContext); LayoutParams params = new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT); mImageView.setLayoutParams(params);/*from w ww.j a v a 2s . c o m*/ this.addView(mImageView); mImageView.setVisibility(GONE); mProgressBar = new ProgressBar(mContext, null, android.R.attr.progressBarStyleInverse); params = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar.setLayoutParams(params); mProgressBar.setIndeterminate(false); this.addView(mProgressBar); mTextView = new TextView(mContext); params = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_IN_PARENT); mTextView.setLayoutParams(params); int left = getResources().getDimensionPixelSize(R.dimen.gallery_percent_tv_padding_left); int top = getResources().getDimensionPixelSize(R.dimen.gallery_percent_tv_padding_top); int right = getResources().getDimensionPixelSize(R.dimen.gallery_percent_tv_padding_right); int bottom = getResources().getDimensionPixelSize(R.dimen.gallery_percent_tv_padding_bottom); mTextView.setPadding(left, top, right, bottom); mTextView.setGravity(Gravity.CENTER); mTextView.setTextColor(Color.WHITE); mTextView.setText(R.string.tip_is_preparing_for_data); mTextView.setVisibility(View.GONE); this.addView(mTextView); mButton = new Button(mContext); params = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT); mButton.setLayoutParams(params); mButton.setGravity(Gravity.CENTER); mButton.setText(R.string.tip_image_button); mButton.setTextColor(Color.WHITE); mButton.setBackgroundResource(R.drawable.btn_check_image); mButton.setVisibility(View.GONE); this.addView(mButton); mButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mImageUrlTask = new AsyncTask<Void, Integer, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { if (mFileData != null) { FileData fileData = FileDataManager.getInstance() .getFileInfoSync(mFileData.getFullpath()); return getOriImage(fileData, new ParamsCallBack() { @Override public void callBack(Object obj) { publishProgress((int) obj); } }); } else { return null; } } @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); mButton.setVisibility(GONE); mTextView.setVisibility(VISIBLE); mProgressBar.setVisibility(VISIBLE); if (values[0] == -1) { mTextView.setText(mContext.getString(R.string.tip_is_loading)); } else { mTextView.setText(values[0] + " %"); } } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); if (mImageView != null && mProgressBar != null) { if (bitmap != null) { mButton.setVisibility(GONE); mImageView.setScaleType(ScaleType.MATRIX); mImageView.setImageBitmap(bitmap); mTextView.setVisibility(View.GONE); mImageView.setVisibility(VISIBLE); mProgressBar.setVisibility(GONE); } else { mButton.setVisibility(GONE); mTextView.setVisibility(VISIBLE); mTextView.setText(R.string.tip_open_image_failed); mProgressBar.setVisibility(View.VISIBLE); } } } }.execute(); } }); }
From source file:org.orange.querysystem.content.TabsAdapter.java
private void setTabForIfLowerThanHONEYCOMB() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { View child = mTabHost.getTabWidget().getChildAt(getCount() - 1); child.setBackgroundColor(0xFFB5E61D); TextView tv = (TextView) child.findViewById(android.R.id.title); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //?? params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); //? params.setMargins(dp2px(10), dp2px(4), dp2px(10), dp2px(4)); child.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT; }/*from w w w . ja v a2s . c o m*/ }
From source file:com.wms.opensource.shopfast.fragment.ProductsInCollectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);/*from ww w .j a va 2 s . c o m*/ return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewPreview = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewPreview.setLayoutParams(imageViewParams); imageViewPreview.setVisibility(View.INVISIBLE); imageViewPreview.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(ProductsInCollectionFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewPreview); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading products, display products if they have been saved before. String productsFilePath = StorageUtil.getTempDirectoryPath(getActivity()) + "/" + PersistFileNameProvider.getProductsFileName(collectionID, page); boolean productsFileExists = FileUtil.fileExist(productsFilePath); if (productsFileExists) { loadProductsFromLocalTask = new LoadCachedProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadProductsFromLocalTask.execute(collectionID); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkConnection(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { loadShopifyProductsTask = new LoadProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadShopifyProductsTask.execute(collectionID); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:info.tellmetime.DaydreamService.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); setInteractive(true);/*from w w w .j a va2 s . c o m*/ setFullscreen(true); setContentView(R.layout.daydream); LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); SharedPreferences settings = getSharedPreferences("PREFS", Context.MODE_PRIVATE); mHighlightColor = settings.getInt(TellmetimeActivity.HIGHLIGHT, Color.WHITE); mBacklightColor = settings.getInt(TellmetimeActivity.BACKLIGHT, getResources().getColor(R.color.backlight_light)); mMinutesSize = settings.getInt(TellmetimeActivity.MINUTES_SIZE, 36); isNightMode = settings.getBoolean(TellmetimeActivity.NIGHTMODE, false); setScreenBright(!isNightMode); findViewById(R.id.overlay).setBackgroundColor( getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent)); RelativeLayout mSurface = (RelativeLayout) findViewById(R.id.surface); mSurface.setBackgroundColor( settings.getInt(TellmetimeActivity.BACKGROUND, getResources().getColor(R.color.background))); switch (settings.getInt(TellmetimeActivity.BACKGROUND_MODE, TellmetimeActivity.MODE_BACKGROUND_SOLID)) { case TellmetimeActivity.MODE_BACKGROUND_WALLPAPER: ((ImageView) findViewById(R.id.background_image)) .setImageDrawable(WallpaperManager.getInstance(this).getDrawable()); break; case TellmetimeActivity.MODE_BACKGROUND_IMAGE: try { ((ImageView) findViewById(R.id.background_image)).setImageBitmap(BitmapFactory.decodeStream( new FileInputStream(new File(getFilesDir(), TellmetimeActivity.IMAGE_FILE_NAME)))); } catch (Exception ignored) { // Image is not set, set background color loaded from setting is visible. } break; } mShorterEdge = Math.min(getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels); mDensity = getResources().getDisplayMetrics().density; RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.width = mShorterEdge; mClock.setLayoutParams(lp); Typeface mTypeface = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); final float mItemSize = mShorterEdge / mClock.getChildCount(); final int mRowMargin = (int) -(mItemSize / 2.2); for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); params.bottomMargin = mRowMargin; row.setLayoutParams(params); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); tv.setTypeface(mTypeface); tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize); tv.setTextColor(mBacklightColor); tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } } LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams(); params.bottomMargin = 0; lastRow.setLayoutParams(params); TextView twenty = (TextView) findViewById(R.id.twenty); params = (LinearLayout.LayoutParams) twenty.getLayoutParams(); params.leftMargin = 0; twenty.setLayoutParams(params); inflateMinutesIndicators(); }
From source file:net.pocketmagic.android.carousel.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //no keyboard unless requested by user getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // compute screen size and scaling Singleton.getInstance().InitGUIFrame(this); int padding = m_Inst.Scale(10); // create the interface : full screen container RelativeLayout panel = new RelativeLayout(this); panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); panel.setPadding(padding, padding, padding, padding); panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.WHITE, Color.GRAY })); setContentView(panel);/* www.jav a 2 s .c om*/ // copy images from assets to sdcard AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false); //Create carousel view documents ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>(); for (int i = 0; i < 1000; i++) { CarouselDataItem docu; if (i % 4 == 0) docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image " + i); else if (i % 4 == 1) docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image " + i); else if (i % 4 == 2) docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image " + i); else docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image " + i); Docus.add(docu); } // add the serach filter EditText etSearch = new EditText(this); etSearch.setHint("Search your documents"); etSearch.setSingleLine(); etSearch.setTextColor(Color.BLACK); etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0); AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1); etSearch.addTextChangedListener((TextWatcher) this); // add logo TextView tv = new TextView(this); tv.setTextColor(Color.BLACK); tv.setText("www.pocketmagic.net"); AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1); // create the carousel CarouselView coverFlow = new CarouselView(this); // create adapter and specify device independent items size (scaling) // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/ m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300)); coverFlow.setAdapter(m_carouselAdapter); coverFlow.setSpacing(-1 * m_Inst.Scale(150)); coverFlow.setSelection(Integer.MAX_VALUE / 2, true); coverFlow.setAnimationDuration(1000); coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this); AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_IN_PARENT } }, -1, -1); }