List of usage examples for android.widget RelativeLayout ALIGN_PARENT_LEFT
int ALIGN_PARENT_LEFT
To view the source code for android.widget RelativeLayout ALIGN_PARENT_LEFT.
Click Source Link
From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override/*from ww w . java2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LOG_TAG, "onCreate() : " + savedInstanceState); setContentView(R.layout.activity_jet_pack_elf); // App Invites mInvitesFragment = AppInvitesFragment.getInstance(this); // App Measurement mMeasurement = FirebaseAnalytics.getInstance(this); MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_rocket)); // [ANALYTICS SCREEN]: Rocket Sleigh AnalyticsManager.initializeAnalyticsTracker(this); AnalyticsManager.sendScreenView(R.string.analytics_screen_rocket); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ImmersiveModeHelper.setImmersiveSticky(getWindow()); ImmersiveModeHelper.installSystemUiVisibilityChangeListener(getWindow()); } mIntroVideo = (VideoView) findViewById(R.id.intro_view); mIntroControl = findViewById(R.id.intro_control_view); if (savedInstanceState == null) { String path = "android.resource://" + getPackageName() + "/" + R.raw.jp_background; mBackgroundPlayer = new MediaPlayer(); try { mBackgroundPlayer.setDataSource(this, Uri.parse(path)); mBackgroundPlayer.setLooping(true); mBackgroundPlayer.prepare(); mBackgroundPlayer.start(); } catch (IOException e) { e.printStackTrace(); } boolean nomovie = false; if (getIntent().getBooleanExtra("nomovie", false)) { nomovie = true; } else if (Build.MANUFACTURER.toUpperCase().contains("SAMSUNG")) { // nomovie = true; } if (!nomovie) { mIntroControl.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { endIntro(); } }); path = "android.resource://" + getPackageName() + "/" + R.raw.intro_wipe; mIntroVideo.setVideoURI(Uri.parse(path)); mIntroVideo.setOnCompletionListener(this); mIntroVideo.start(); mMoviePlaying = true; } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // For hit indication. mHandler = new Handler(); // Get the main UI handler for posting update events DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); Log.d(LOG_TAG, "Width: " + dm.widthPixels + " Height: " + dm.heightPixels + " Density: " + dm.density); mScreenHeight = dm.heightPixels; mScreenWidth = dm.widthPixels; mSlotWidth = mScreenWidth / SLOTS_PER_SCREEN; // Setup the random number generator mRandom = new Random(); mRandom.setSeed(System.currentTimeMillis()); // This is ok. We are not looking for cryptographically secure random here! mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Setup the background/foreground mBackgroundLayout = (LinearLayout) findViewById(R.id.background_layout); mBackgroundScroll = (HorizontalScrollView) findViewById(R.id.background_scroll); mForegroundLayout = (LinearLayout) findViewById(R.id.foreground_layout); mForegroundScroll = (HorizontalScrollView) findViewById(R.id.foreground_scroll); mBackgrounds = new Bitmap[6]; mBackgrounds2 = new Bitmap[6]; mExitTransitions = new Bitmap[6]; mEntryTransitions = new Bitmap[6]; // Need to vertically scale background to fit the screen. Checkthe image size // compared to screen size and scale appropriately. We will also use the matrix to translate // as we move through the level. Bitmap bmp = BitmapFactory.decodeResource(getResources(), BACKGROUNDS[0]); Log.d(LOG_TAG, "Bitmap Width: " + bmp.getWidth() + " Height: " + bmp.getHeight() + " Screen Width: " + dm.widthPixels + " Height: " + dm.heightPixels); mScaleY = (float) dm.heightPixels / (float) bmp.getHeight(); mScaleX = (float) (dm.widthPixels * 2) / (float) bmp.getWidth(); // Ensure that a single bitmap is 2 screens worth of time. (Stock xxhdpi image is 3840x1080) if ((mScaleX != 1.0f) || (mScaleY != 1.0f)) { Bitmap tmp = Bitmap.createScaledBitmap(bmp, mScreenWidth * 2, mScreenHeight, false); if (tmp != bmp) { bmp.recycle(); bmp = tmp; } } BackgroundLoadTask.createTwoBitmaps(bmp, mBackgrounds, mBackgrounds2, 0); // Load the initial background view addNextImages(0); addNextImages(0); mWoodObstacles = new TreeMap<Integer, Bitmap>(); mWoodObstacleList = new ArrayList<Integer>(); mWoodObstacleIndex = 0; // We need the bitmaps, so we do pre-load here synchronously. initObstaclesAndPreLoad(WOOD_OBSTACLES, 3, mWoodObstacles, mWoodObstacleList); mCaveObstacles = new TreeMap<Integer, Bitmap>(); mCaveObstacleList = new ArrayList<Integer>(); mCaveObstacleIndex = 0; initObstacles(CAVE_OBSTACLES, 2, mCaveObstacleList); mFactoryObstacles = new TreeMap<Integer, Bitmap>(); mFactoryObstacleList = new ArrayList<Integer>(); mFactoryObstacleIndex = 0; initObstacles(FACTORY_OBSTACLES, 2, mFactoryObstacleList); // Setup the elf mElf = (ImageView) findViewById(R.id.elf_image); mThrust = (ImageView) findViewById(R.id.thrust_image); mElfLayout = (LinearLayout) findViewById(R.id.elf_container); loadElfImages(); updateElf(false); // Elf should be the same height relative to the height of the screen on any platform. Matrix scaleMatrix = new Matrix(); mElfScale = ((float) dm.heightPixels * 0.123f) / (float) mElfBitmap.getHeight(); // On a 1920x1080 xxhdpi screen, this makes the elf 133 pixels which is the height of the drawable. scaleMatrix.preScale(mElfScale, mElfScale); mElf.setImageMatrix(scaleMatrix); mThrust.setImageMatrix(scaleMatrix); mElfPosX = (dm.widthPixels * 15) / 100; // 15% Into the screen mElfPosY = (dm.heightPixels - ((float) mElfBitmap.getHeight() * mElfScale)) / 2; // About 1/2 way down. mElfVelX = (float) dm.widthPixels / 3000.0f; // We start at 3 seconds for a full screen to scroll. mGravityAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((1.2 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 1.2 seconds mThrustAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((0.7 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 0.7 seconds // Setup the control view mControlView = findViewById(R.id.control_view); mGestureDetector = new GestureDetector(this, this); mGestureDetector.setIsLongpressEnabled(true); mGestureDetector.setOnDoubleTapListener(this); mScoreLabel = getString(R.string.score); mScoreText = (TextView) findViewById(R.id.score_text); mScoreText.setText("0"); mPlayPauseButton = (ImageView) findViewById(R.id.play_pause_button); mExit = (ImageView) findViewById(R.id.exit); // Is Tv? mIsTv = TvUtil.isTv(this); if (mIsTv) { mScoreText.setText(mScoreLabel + ": 0"); mPlayPauseButton.setVisibility(View.GONE); mExit.setVisibility(View.GONE); // move scoreLayout position to the Top-Right corner. View scoreLayout = findViewById(R.id.score_layout); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) scoreLayout.getLayoutParams(); params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); final int marginTop = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_top); final int marginLeft = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_left); params.setMargins(marginLeft, marginTop, 0, 0); scoreLayout.setLayoutParams(params); scoreLayout.setBackground(null); scoreLayout.findViewById(R.id.score_text_seperator).setVisibility(View.GONE); } else { mPlayPauseButton.setEnabled(false); mPlayPauseButton.setOnClickListener(this); mExit.setOnClickListener(this); } mBigPlayButtonLayout = findViewById(R.id.big_play_button_layout); mBigPlayButtonLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // No interaction with the screen below this one. return true; } }); mBigPlayButton = (ImageButton) findViewById(R.id.big_play_button); mBigPlayButton.setOnClickListener(this); // For showing points when getting presents. mPlus100 = (ImageView) findViewById(R.id.plus_100); m100Anim = new AlphaAnimation(1.0f, 0.0f); m100Anim.setDuration(1000); m100Anim.setFillBefore(true); m100Anim.setFillAfter(true); mPlus500 = (ImageView) findViewById(R.id.plus_500); m500Anim = new AlphaAnimation(1.0f, 0.0f); m500Anim.setDuration(1000); m500Anim.setFillBefore(true); m500Anim.setFillAfter(true); // Get the obstacle layouts ready. No obstacles on the first screen of a level. // Prime with a screen full of obstacles. mObstacleLayout = (LinearLayout) findViewById(R.id.obstacles_layout); mObstacleScroll = (HorizontalScrollView) findViewById(R.id.obstacles_scroll); // Initialize the present bitmaps. These are used repeatedly so we keep them loaded. mGiftBoxes = new Bitmap[GIFT_BOXES.length]; for (int i = 0; i < GIFT_BOXES.length; i++) { mGiftBoxes[i] = BitmapFactory.decodeResource(getResources(), GIFT_BOXES[i]); } // Add starting obstacles. First screen has presents. Next 3 get obstacles. addFirstScreenPresents(); // addFinalPresentRun(); // This adds 2 screens of presents // addNextObstacles(0, 1); addNextObstacles(0, 3); // Setup the sound pool mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); mSoundPool.setOnLoadCompleteListener(this); mCrashSound1 = mSoundPool.load(this, R.raw.jp_crash_1, 1); mCrashSound2 = mSoundPool.load(this, R.raw.jp_crash_2, 1); mCrashSound3 = mSoundPool.load(this, R.raw.jp_crash_3, 1); mGameOverSound = mSoundPool.load(this, R.raw.jp_game_over, 1); mJetThrustSound = mSoundPool.load(this, R.raw.jp_jet_thrust, 1); mLevelUpSound = mSoundPool.load(this, R.raw.jp_level_up, 1); mScoreBigSound = mSoundPool.load(this, R.raw.jp_score_big, 1); mScoreSmallSound = mSoundPool.load(this, R.raw.jp_score_small, 1); mJetThrustStream = 0; if (!mMoviePlaying) { doCountdown(); } }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java
private void setPhotoSide(MessageListItemViews tagView, ArrowPosition pos) { System.out.println("MessageAdapter.java in setPhotoSide() "); LayoutParams lp = (RelativeLayout.LayoutParams) tagView.quickContactView.getLayoutParams(); lp.addRule(// w ww . j a v a 2s . c o m (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_RIGHT : RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule( (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_LEFT : RelativeLayout.ALIGN_PARENT_RIGHT, 0); lp = (RelativeLayout.LayoutParams) tagView.containterBlock.getLayoutParams(); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.LEFT_OF : RelativeLayout.RIGHT_OF, R.id.quick_contact_photo); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.RIGHT_OF : RelativeLayout.LEFT_OF, 0); tagView.quickContactView.setPosition(pos); }
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Lays out the body using the back images. */// ww w. j a v a 2 s. c o m private void setMaleBack() { front = false; RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(dipToPixels(42), dipToPixels(65)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(303); head.setLayoutParams(lp); head.setBackground(getResources().getDrawable(R.drawable.male_head_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(58), dipToPixels(102)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(205); torso.setLayoutParams(lp); torso.setBackground(getResources().getDrawable(R.drawable.male_torso_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(66), dipToPixels(34)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.bottomMargin = dipToPixels(174); shorts.setLayoutParams(lp); shorts.setBackground(getResources().getDrawable(R.drawable.male_butt_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(39), dipToPixels(73)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(108); lp.leftMargin = dipToPixels(141); r_top.setLayoutParams(lp); r_top.setBackground(getResources().getDrawable(R.drawable.male_leftthigh_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(22), dipToPixels(72)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(42); lp.leftMargin = dipToPixels(137); r_bot.setLayoutParams(lp); r_bot.setBackground(getResources().getDrawable(R.drawable.male_leftcalf_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(20), dipToPixels(41)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(3); lp.leftMargin = dipToPixels(129); r_foot.setLayoutParams(lp); r_foot.setBackground(getResources().getDrawable(R.drawable.male_leftfoot_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(39), dipToPixels(71)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(107); lp.leftMargin = dipToPixels(180); l_top.setLayoutParams(lp); l_top.setBackground(getResources().getDrawable(R.drawable.male_rightthigh_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(22), dipToPixels(72)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(41); lp.leftMargin = dipToPixels(201); l_bot.setLayoutParams(lp); l_bot.setBackground(getResources().getDrawable(R.drawable.male_rightcalf_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(20), dipToPixels(41)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(2); lp.leftMargin = dipToPixels(211); l_foot.setLayoutParams(lp); l_foot.setBackground(getResources().getDrawable(R.drawable.male_rightfoot_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(71), dipToPixels(91)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(87); r_arm.setLayoutParams(lp); r_arm.setBackground(getResources().getDrawable(R.drawable.male_leftarm_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(186); lp.leftMargin = dipToPixels(61); r_hand.setLayoutParams(lp); r_hand.setBackground(getResources().getDrawable(R.drawable.male_lefthand_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(71), dipToPixels(91)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(215); lp.leftMargin = dipToPixels(200); l_arm.setLayoutParams(lp); l_arm.setBackground(getResources().getDrawable(R.drawable.male_rightarm_back_3x)); lp = new RelativeLayout.LayoutParams(dipToPixels(35), dipToPixels(35)); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.bottomMargin = dipToPixels(185); lp.leftMargin = dipToPixels(263); l_hand.setLayoutParams(lp); l_hand.setBackground(getResources().getDrawable(R.drawable.male_righthand_back_3x)); bodyLayout.invalidate(); }
From source file:org.zywx.wbpalmstar.engine.universalex.EUExBase.java
protected final void adptLayoutParams(RelativeLayout.LayoutParams rParms, FrameLayout.LayoutParams outParm) { if (null == rParms) { return;/*from w w w . j ava 2s . c om*/ } int TRUE = RelativeLayout.TRUE; int ALIGN_PARENT_LEFT = RelativeLayout.ALIGN_PARENT_LEFT; int ALIGN_PARENT_TOP = RelativeLayout.ALIGN_PARENT_TOP; int ALIGN_PARENT_RIGHT = RelativeLayout.ALIGN_PARENT_RIGHT; int ALIGN_PARENT_BOTTOM = RelativeLayout.ALIGN_PARENT_BOTTOM; int CENTER_IN_PARENT = RelativeLayout.CENTER_IN_PARENT; int CENTER_HORIZONTAL = RelativeLayout.CENTER_HORIZONTAL; int CENTER_VERTICAL = RelativeLayout.CENTER_VERTICAL; try { int[] rules = rParms.getRules(); if (rules[ALIGN_PARENT_LEFT] == TRUE) { outParm.gravity |= Gravity.LEFT; } if (rules[ALIGN_PARENT_TOP] == TRUE) { outParm.gravity |= Gravity.TOP; } if (rules[ALIGN_PARENT_RIGHT] == TRUE) { outParm.gravity |= Gravity.RIGHT; } if (rules[ALIGN_PARENT_BOTTOM] == TRUE) { outParm.gravity |= Gravity.BOTTOM; } if (rules[CENTER_IN_PARENT] == TRUE) { outParm.gravity |= Gravity.CENTER; } if (rules[CENTER_HORIZONTAL] == TRUE) { outParm.gravity |= Gravity.CENTER_HORIZONTAL; } if (rules[CENTER_VERTICAL] == TRUE) { outParm.gravity |= Gravity.CENTER_VERTICAL; } } catch (Exception e) { ; } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeLayout() { // make fonts this.makeFonts(); // clear the existing themes. themes.clear();/*from ww w. j ava2s .co m*/ // add themes // String name,int foregroundColor,int backgroundColor,int controlColor,int controlHighlightColor,int seekBarColor,int seekThumbColor,int selectorColor,int selectionColor,String portraitName,String landscapeName,String doublePagedName,int bookmarkId themes.add(new Theme("white", Color.BLACK, 0xffffffff, Color.argb(240, 94, 61, 35), Color.LTGRAY, Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95), Color.DKGRAY, 0x22222222, "Phone-Portrait-White.png", "Phone-Landscape-White.png", "Phone-Landscape-Double-White.png", R.drawable.bookmark2x)); themes.add(new Theme("brown", Color.BLACK, 0xffece3c7, Color.argb(240, 94, 61, 35), Color.argb(255, 255, 255, 255), Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95), Color.DKGRAY, 0x22222222, "Phone-Portrait-Brown.png", "Phone-Landscape-Brown.png", "Phone-Landscape-Double-Brown.png", R.drawable.bookmark2x)); themes.add(new Theme("black", Color.LTGRAY, 0xff323230, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY, 0x77777777, null, null, "Phone-Landscape-Double-Black.png", R.drawable.bookmarkgray2x)); themes.add(new Theme("Leaf", 0xFF1F7F0E, 0xffF8F7EA, 0xFF186D08, Color.LTGRAY, 0xFF186D08, 0xFF186D08, Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x)); themes.add(new Theme("", 0xFFA13A0A, 0xFFF6DFD9, 0xFFA13A0A, 0xFFDC4F0E, 0xFFA13A0A, 0xFFA13A0A, Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x)); this.setBrightness((float) setting.brightness); // create highlights object to contains highlights of this book. highlights = new Highlights(); Bundle bundle = getIntent().getExtras(); fileName = bundle.getString("BOOKNAME"); author = bundle.getString("AUTHOR"); title = bundle.getString("TITLE"); bookCode = bundle.getInt("BOOKCODE"); if (pagePositionInBook == -1) pagePositionInBook = bundle.getDouble("POSITION"); themeIndex = setting.theme; this.isGlobalPagination = bundle.getBoolean("GLOBALPAGINATION"); this.isRTL = bundle.getBoolean("RTL"); this.isVerticalWriting = bundle.getBoolean("VERTICALWRITING"); this.isDoublePagedForLandscape = bundle.getBoolean("DOUBLEPAGED"); // if (this.isRTL) this.isDoublePagedForLandscape = false; // In RTL mode, SDK does not support double paged. ePubView = new RelativeLayout(this); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); ePubView.setLayoutParams(rlp); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height if (this.getOSVersion() >= 11) { rv = new ReflowableControl(this); // in case that device supports transparent webkit, the background image under the content can be shown. in some devices, content may be overlapped. } else { rv = new ReflowableControl(this, getCurrentTheme().backgroundColor); // in case that device can not support transparent webkit, the background color will be set in one color. } // if false highlight will be drawed on the back of text - this is default. // for the very old devices of which GPU does not support transparent webView background, set the value to true. rv.setDrawingHighlightOnFront(false); // set the bookCode to identify the book file. rv.bookCode = this.bookCode; // set bitmaps for engine. rv.setPagesStackImage(this.getBitmap("PagesStack.png")); rv.setPagesCenterImage(this.getBitmap("PagesCenter.png")); // for epub3 which has page-progression-direction="rtl", rv.isRTL() will return true. // for old RTL epub which does not have <spine toc="ncx" page-progression-direction="rtl"> in opf file. // you can enforce RTL mode. /* // delay times for proper operations. // !! DO NOT SET these values if there's no issue on your epub reader. !! // !! if delayTime is decresed, performance will be increase // !! if delayTime is set to too low value, a lot of problem can be occurred. // bringDelayTime(default 500 ms) is for curlView and mainView transition - if the value is too short, blink may happen. rv.setBringDelayTime(500); // reloadDelayTime(default 100) is used for delay before reload (eg. changeFont, loadChapter or etc) rv.setReloadDelayTime(100); // reloadDelayTimeForRotation(default 1000) is used for delay before rotation rv.setReloadDelayTimeForRotation(1000); // retotaionDelayTime(default 1500) is used for delay after rotation. rv.setRotationDelayTime(1500); // finalDelayTime(default 500) is used for the delay after loading chapter. rv.setFinalDelayTime(500); // rotationFactor affects the delayTime before Rotation. default value 1.0f rv.setRotationFactor(1.0f); // If recalcDelayTime is too short, setContentBackground function failed to work properly. rv.setRecalcDelayTime(2500); */ // set the max width or height for background. rv.setMaxSizeForBackground(1024); // rv.setBaseDirectory(SkySetting.getStorageDirectory() + "/books"); // rv.setBookName(fileName); // set the file path of epub to open // Be sure that the file exists before setting. rv.setBookPath(SkySetting.getStorageDirectory() + "/books/" + fileName); // if true, double pages will be displayed on landscape mode. rv.setDoublePagedForLandscape(this.isDoublePagedForLandscape); // set the initial font style for book. rv.setFont(setting.fontName, this.getRealFontSize(setting.fontSize)); // set the initial line space for book. rv.setLineSpacing(this.getRealLineSpace(setting.lineSpacing)); // the value is supposed to be percent(%). // set the horizontal gap(margin) on both left and right side of each page. rv.setHorizontalGapRatio(0.30); // set the vertical gap(margin) on both top and bottom side of each page. rv.setVerticalGapRatio(0.22); // set the HighlightListener to handle text highlighting. rv.setHighlightListener(new HighlightDelegate()); // set the PageMovedListener which is called whenever page is moved. rv.setPageMovedListener(new PageMovedDelegate()); // set the SelectionListener to handle text selection. rv.setSelectionListener(new SelectionDelegate()); // set the pagingListener which is called when GlobalPagination is true. this enables the calculation for the total number of pages in book, not in chapter. rv.setPagingListener(new PagingDelegate()); // set the searchListener to search keyword. rv.setSearchListener(new SearchDelegate()); // set the stateListener to monitor the state of sdk engine. rv.setStateListener(new StateDelegate()); // set the clickListener which is called when user clicks rv.setClickListener(new ClickDelegate()); // set the bookmarkListener to toggle bookmark rv.setBookmarkListener(new BookmarkDelegate()); // set the scriptListener to set custom javascript. rv.setScriptListener(new ScriptDelegate()); // enable/disable scroll mode rv.setScrollMode(false); // for some anroid device, when rendering issues are occurred, use "useSoftwareLayer" // rv.useSoftwareLayer(); // In search keyword, if true, sdk will return search result with the full information such as position, pageIndex. rv.setFullSearch(true); // if true, sdk will return raw text for search result, highlight text or body text without character escaping. rv.setRawTextRequired(false); // if true, sdk will read the content of book directry from file system, not via Internal server. // rv.setDirectRead(true); // If you want to make your own provider, please look into EpubProvider.java in Advanced demo. // EpubProvider epubProvider = new EpubProvider(); // rv.setContentProvider(epubProvider); // SkyProvider is the default ContentProvider which is presented with SDK. // SkyProvider can read the content of epub file without unzipping. // SkyProvider is also fully integrated with SkyDRM solution. SkyProvider skyProvider = new SkyProvider(); skyProvider.setKeyListener(new KeyDelegate()); rv.setContentProvider(skyProvider); // set the start positon to open the book. rv.setStartPositionInBook(pagePositionInBook); // DO NOT USE BELOW, if true , sdk will use DOM to highlight text. // rv.useDOMForHighlight(false); // if true, globalPagination will be activated. // this enables the calculation of page number based on entire book ,not on each chapter. // this globalPagination consumes huge computing power. // AVOID GLOBAL PAGINATION FOR LOW SPEC DEVICES. rv.setGlobalPagination(this.isGlobalPagination); // set the navigation area on both left and right side to go to the previous or next page when the area is clicked. rv.setNavigationAreaWidthRatio(0.1f); // both left and right side. // set the device locked to prevent Rotation. rv.setRotationLocked(setting.lockRotation); isRotationLocked = setting.lockRotation; // set the mediaOverlayListener for MediaOverlay. rv.setMediaOverlayListener(new MediaOverlayDelegate()); // set the audio playing based on Sequence. rv.setSequenceBasedForMediaOverlay(false); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.width = LayoutParams.MATCH_PARENT; params.height = LayoutParams.MATCH_PARENT; rv.setLayoutParams(params); this.applyThemeToRV(themeIndex); if (this.isFullScreenForNexus && SkyUtility.isNexus() && Build.VERSION.SDK_INT >= 19) { rv.setImmersiveMode(true); } // If you want to get the license key for commercial use, please email us (skytree21@gmail.com). // Without the license key, watermark message will be shown in background. rv.setLicenseKey("a99b-3914-a63b-8ecb"); // set PageTransition Effect int transitionType = bundle.getInt("transitionType"); if (transitionType == 0) { rv.setPageTransition(PageTransition.None); } else if (transitionType == 1) { rv.setPageTransition(PageTransition.Slide); } else if (transitionType == 2) { rv.setPageTransition(PageTransition.Curl); } // setCurlQuality effects the image quality when tuning page in Curl Transition Mode. // If "Out of Memory" occurs in high resolution devices with big screen, // this value should be decreased like 0.25f or below. if (this.getMaxSize() > 1280) { rv.setCurlQuality(0.5f); } // set the color of text selector. rv.setSelectorColor(getCurrentTheme().selectorColor); // set the color of text selection area. rv.setSelectionColor(getCurrentTheme().selectionColor); // setCustomDrawHighlight & setCustomDrawCaret work only if SDK >= 11 // if true, sdk will ask you how to draw the highlighted text rv.setCustomDrawHighlight(true); // if true, sdk will require you to draw the custom selector. rv.setCustomDrawCaret(true); rv.setFontUnit("px"); rv.setFingerTractionForSlide(true); rv.setVideoListener(new VideoDelegate()); // make engine not to send any event to iframe // if iframe clicked, onIFrameClicked will be fired with source of iframe // By Using that source of iframe, you can load the content of iframe in your own webView or another browser. rv.setSendingEventsToIFrameEnabled(false); // make engine send any event to video(tag) or not // if video tag is clicked, onVideoClicked will be fired with source of iframe // By Using that source of video, you can load the content of video in your own media controller or another browser. rv.setSendingEventsToVideoEnabled(true); // make engine send any event to video(tag) or not // if video tag is clicked, onVideoClicked will be fired with source of iframe // By Using that source of video, you can load the content of video in your own media controller or another browser. rv.setSendingEventsToAudioEnabled(true); // if true, sdk will return the character offset from the chapter beginning , not from element index. // then startIndex, endIndex of highlight will be 0 (zero) rv.setGlobalOffset(true); // if true, sdk will return the text of each page in the PageInformation object which is passed in onPageMoved event. rv.setExtractText(true); ePubView.addView(rv); this.makeControls(); this.makeBoxes(); this.makeIndicator(); this.recalcFrames(); if (this.isRTL) { this.seekBar.setReversed(true); } setContentView(ePubView); this.isInitialized = true; }
From source file:com.google.sample.cast.refplayer.Synchronization.java
/** * Setting the Previewing mode(Editing mode) clip bar (orange) *///from w w w. j av a 2 s. c o m private void setPreviewClip() { if (pseekBar != null) { pseekBar.setVisibility(View.GONE); } prev_start_p_ForPreview = prev_start_p; prev_end_p_ForPreview = prev_end_p; pseekBar = new RangeSeekBar(prev_start_p_ForPreview, prev_end_p_ForPreview, this); pseekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>() { @Override public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer start_p, Integer end_p) { // handle changed range values Log.i(TAG, "Selected new range values: MIN=" + start_p + ", MAX=" + end_p); mClipDuration.setText(" " + com.google.android.libraries.cast.companionlibrary.utils.Utils .formatMillis(prev_end_p_ForPreview - prev_start_p_ForPreview) + " "); playpause = false; mPlayPause.setImageDrawable(getResources().getDrawable(R.drawable.ic_av_play_dark)); if (start_p != prev_start_p_ForPreview) { mVideoView.seekTo(start_p); mVideoView.start(); SystemClock.sleep(100); mVideoView.pause(); prev_start_p_ForPreview = start_p; prev_start_p = start_p; } if (end_p != prev_end_p_ForPreview) { mVideoView.seekTo(end_p); mVideoView.start(); SystemClock.sleep(100); mVideoView.pause(); prev_end_p_ForPreview = end_p; prev_end_p = end_p; } } }); // add RangeSeekBar to pre-defined layout RelativeLayout layout = (RelativeLayout) findViewById(R.id.synchronization); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, pseekBar.getId()); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, pseekBar.getId()); params.addRule(RelativeLayout.BELOW, mVideoView.getId()); pseekBar.setVisibility(View.VISIBLE); layout.addView(pseekBar, params); }
From source file:im.vector.fragments.VectorRecentsListFragment.java
/** * Start the drag and drop mode//from w w w. ja va 2 s . c o m */ private void startDragAndDrop() { mIsWaitingTagOrderEcho = false; if (isDragAndDropSupported() && groupIsMovable(mRecentsListView.getTouchedGroupPosition())) { // enable the drag and drop mode mAdapter.setIsDragAndDropMode(true); mSession.getDataHandler().removeListener(mEventsListener); int groupPos = mRecentsListView.getTouchedGroupPosition(); int childPos = mRecentsListView.getTouchedChildPosition(); mDraggedView = mAdapter.getChildView(groupPos, childPos, false, null, null); mDraggedView.setBackgroundColor(getResources().getColor(R.color.vector_silver_color)); mDraggedView.setAlpha(0.3f); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); mSelectedCellLayout.addView(mDraggedView, params); mDestGroupPosition = mOriginGroupPosition = groupPos; mDestChildPosition = mOriginChildPosition = childPos; onTouchMove(mRecentsListView.getTouchedY(), groupPos, childPos); } }
From source file:com.aimfire.demo.CameraActivity.java
private void adjustUIControls(int rotation) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mCaptureButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mCaptureButton.setLayoutParams(layoutParams); mCaptureButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mPvButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ABOVE, 0); layoutParams.addRule(RelativeLayout.BELOW, R.id.capture_button); mPvButton.setLayoutParams(layoutParams); mPvButton.setRotation(rotation);/*from ww w .j ava2 s . co m*/ /* layoutParams = (RelativeLayout.LayoutParams)mFbButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ABOVE, R.id.capture_button); layoutParams.addRule(RelativeLayout.BELOW, 0); mFbButton.setLayoutParams(layoutParams); mFbButton.setRotation(rotation); */ layoutParams = (RelativeLayout.LayoutParams) mExitButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); mExitButton.setLayoutParams(layoutParams); mExitButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mView3DButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mView3DButton.setLayoutParams(layoutParams); mView3DButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mModeButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.LEFT_OF, 0); layoutParams.addRule(RelativeLayout.RIGHT_OF, 0); mModeButton.setLayoutParams(layoutParams); mModeButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mLevelButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); mLevelButton.setLayoutParams(layoutParams); mLevelButton.setRotation(rotation); CustomToast.setRotation(rotation); }
From source file:im.neon.fragments.VectorRecentsListFragment.java
/** * Start the drag and drop mode//from ww w . ja va2s . co m */ private void startDragAndDrop() { mIsWaitingTagOrderEcho = false; mIsWaitingDirectChatEcho = false; if (isDragAndDropSupported() && groupIsMovable(mRecentsListView.getTouchedGroupPosition())) { int groupPos = mRecentsListView.getTouchedGroupPosition(); int childPos = mRecentsListView.getTouchedChildPosition(); try { mDraggedView = mAdapter.getChildView(groupPos, childPos, false, null, null); } catch (Exception e) { Log.e(LOG_TAG, "## startDragAndDrop() : getChildView failed " + e.getMessage()); return; } // enable the drag and drop mode mAdapter.setIsDragAndDropMode(true); mSession.getDataHandler().removeListener(mEventsListener); mDraggedView.setBackgroundColor(getResources().getColor(R.color.vector_silver_color)); mDraggedView.setAlpha(0.3f); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); mSelectedCellLayout.addView(mDraggedView, params); mDestGroupPosition = mOriginGroupPosition = groupPos; mDestChildPosition = mOriginChildPosition = childPos; onTouchMove(mRecentsListView.getTouchedY(), groupPos, childPos); } }
From source file:com.hb.hkm.slidinglayer.SlidLayer.java
private void adjustLayoutParams() { ViewGroup.LayoutParams baseParams = getLayoutParams(); if (baseParams instanceof LayoutParams) { LayoutParams layoutParams = (LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.gravity = Gravity.BOTTOM; break; case STICK_TO_LEFT: layoutParams.gravity = Gravity.LEFT; break; case STICK_TO_RIGHT: layoutParams.gravity = Gravity.RIGHT; break; case STICK_TO_TOP: layoutParams.gravity = Gravity.TOP; break; }//from ww w. j a v a2 s. c o m setLayoutParams(baseParams); } else if (baseParams instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); break; case STICK_TO_LEFT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); break; case STICK_TO_RIGHT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); break; case STICK_TO_TOP: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); break; } } }