List of usage examples for android.widget RelativeLayout ALIGN_PARENT_RIGHT
int ALIGN_PARENT_RIGHT
To view the source code for android.widget RelativeLayout ALIGN_PARENT_RIGHT.
Click Source Link
From source file:net.gaast.giggity.ScheduleViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (Giggity) getApplication();/* w w w . java 2 s . c om*/ pref = PreferenceManager.getDefaultSharedPreferences(app); curView = getResources() .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null); showHidden = pref.getBoolean("show_hidden", false); /* Consider making this a setting, some may find their tablet too small. */ int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE); setContentView(R.layout.schedule_view_activity); View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); drawer = (RelativeLayout) dl.findViewById(R.id.drawer); drawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // NOOP at least for now just so touches don't fall through to bigScreen. } }); ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu); menu.getChildCount(); /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons * (from the schedule) have their own handlers. */ for (int i = 0; i < menu.getChildCount(); ++i) { View btn = menu.getChildAt(i); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient)); onOptionsItemSelectedInt(v.getId()); drawerLayout.closeDrawers(); } }); } if (wantDrawer) { /* Hamburger menu! */ /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */ getActionBar().setDisplayHomeAsUpEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp, R.string.navdrawer_on, R.string.navdrawer_off) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); /* Looks like this code doesn't actually run BTW. Need to figure that out later. */ updateNavDrawer(); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); invalidateOptionsMenu(); } }; } else { drawerLayout.removeView(drawer); } bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen); updateOrientation(getResources().getConfiguration().orientation); viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer); /* TODO: See if I can do this in XML as well? (It's a custom private view.) */ RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); days = new DayButtons(this); viewerContainer.addView(days, lp); redraw = false; timer = new Handler(); /* If the OS informs us that the timezone changes, close this activity so the schedule gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */ tzClose = new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { ScheduleViewActivity.this.finish(); } }; registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED)); if (!getIntent().getAction().equals(Intent.ACTION_VIEW)) return; String url = getIntent().getDataString(); Fetcher.Source fs; if (getIntent().getBooleanExtra("PREFER_CACHED", false)) fs = Fetcher.Source.CACHE_ONLINE; else fs = Fetcher.Source.ONLINE_CACHE; /* I think reminders come in via this activity (instead of straight to itemview) because we may have to reload schedule data? */ if (url.contains("#")) { String parts[] = url.split("#", 2); url = parts[0]; showEventId = parts[1]; } if (app.hasSchedule(url)) { try { sched = app.getSchedule(url, fs); } catch (Exception e) { // Java makes me tired. e.printStackTrace(); } onScheduleLoaded(); } else { loadScheduleAsync(url, fs); } }
From source file:com.andrada.sitracker.ui.fragment.DirectoryChooserFragment.java
@Override public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { assert getActivity() != null; final View view = inflater.inflate(R.layout.directory_chooser, container, false); mBtnConfirm = (Button) view.findViewById(R.id.btnConfirm); Button mBtnCancel = (Button) view.findViewById(R.id.btnCancel); mBtnNavUp = (ImageButton) view.findViewById(R.id.btnNavUp); mBtnCreateFolder = (ImageButton) view.findViewById(R.id.btnCreateFolder); mTxtvSelectedFolderLabel = (TextView) view.findViewById(R.id.txtvSelectedFolderLabel); mTxtvSelectedFolder = (TextView) view.findViewById(R.id.txtvSelectedFolder); ListView mListDirectories = (ListView) view.findViewById(R.id.directoryList); if (!mIsDirectoryChooser) { mBtnConfirm.setVisibility(View.GONE); View horDivider = view.findViewById(R.id.horizontalDivider); if (horDivider != null) { horDivider.setVisibility(View.INVISIBLE); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) horDivider.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL, 0); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); horDivider.setLayoutParams(params); }//ww w . j a va2s . com } else { mBtnConfirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isValidFile(mSelectedDir) && mIsDirectoryChooser) { returnSelectedFolder(); } } }); } mBtnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onCancelChooser(); } }); mListDirectories.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { debug("Selected index: %d", position); if (mFilesInDir != null && position >= 0 && position < mFilesInDir.length) { changeDirectory(mFilesInDir[position]); } } }); mBtnNavUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File parent; if (mSelectedDir != null && (parent = mSelectedDir.getParentFile()) != null) { changeDirectory(parent); } } }); mBtnCreateFolder.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openNewFolderDialog(); } }); if (!getShowsDialog()) { mBtnCreateFolder.setVisibility(View.GONE); } adjustResourceLightness(); mFilenames = new ArrayList<FileDescriptor>(); mListDirectoriesAdapter = new FolderArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, mFilenames); mListDirectories.setAdapter(mListDirectoriesAdapter); final File initialDir; if (mInitialDirectory != null && isValidFile(new File(mInitialDirectory))) { initialDir = new File(mInitialDirectory); } else { initialDir = Environment.getExternalStorageDirectory(); } changeDirectory(initialDir); return view; }
From source file:com.orangelabs.rcs.ri.messaging.chat.ChatCursorAdapter.java
private void bindFileTransferMessage(Cursor cursor, Direction dir, String displayName, int status, ViewHolderFileTransfer holder) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); String mimeType = cursor.getString(holder.columnMimetype); // TODO display distinct icon or thumbnail depending on the mimetype holder.statusText.setText(RiApplication.sFileTransferStates[status]); StringBuilder filename = new StringBuilder(cursor.getString(holder.columnFilename)); long filesize = cursor.getLong(holder.columnFilesize); long transferred = cursor.getLong(holder.columnTransferred); if (filesize != transferred) { holder.progressText.setText(//from w w w.j a v a 2 s .co m filename.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_off); holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_off); } else { int reason = cursor.getInt(holder.columnReasonCode); FileTransfer.ReasonCode reasonCode = FileTransfer.ReasonCode.valueOf(reason); if (FileTransfer.ReasonCode.UNSPECIFIED == reasonCode) { holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_on); holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_on); } else { holder.fileImageOutgoing.setImageResource(R.drawable.ri_filetransfer_off); holder.fileImageIncoming.setImageResource(R.drawable.ri_filetransfer_off); } holder.progressText.setText(filename.append(" (").append(filesize / 1024).append(" Kb)").toString()); } if (Direction.OUTGOING == dir) { boolean undeliveredExpiration = cursor.getInt(holder.columnExpiredDelivery) == 1; holder.undeliveredIcon.setVisibility(undeliveredExpiration ? View.VISIBLE : View.GONE); holder.contactText.setVisibility(View.INVISIBLE); holder.fileImageIncoming.setVisibility(View.GONE); holder.fileImageOutgoing.setVisibility(View.VISIBLE); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else { holder.undeliveredIcon.setVisibility(View.GONE); holder.fileImageIncoming.setVisibility(View.VISIBLE); holder.fileImageOutgoing.setVisibility(View.GONE); if (displayName != null) { holder.contactText.setVisibility(View.VISIBLE); holder.contactText.setText(displayName); } else { holder.contactText.setVisibility(View.INVISIBLE); } lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } holder.filetransferItemLayout.setLayoutParams(lp); }
From source file:com.nextgis.mobile.MapFragment.java
protected void addMapButtons(RelativeLayout rl) { mivZoomIn = new ImageView(getActivity()); mivZoomIn.setImageResource(R.drawable.ic_plus); //mivZoomIn.setId(R.drawable.ic_plus); mivZoomOut = new ImageView(getActivity()); mivZoomOut.setImageResource(R.drawable.ic_minus); //mivZoomOut.setId(R.drawable.ic_minus); final ImageView ivMark = new ImageView(getActivity()); ivMark.setImageResource(R.drawable.ic_mark); //ivMark.setId(R.drawable.ic_mark); //show zoom level between plus and minus mivZoomLevel = new TextView(getActivity()); //ivZoomLevel.setAlpha(150); mivZoomLevel.setId(R.drawable.ic_zoomlevel); final float scale = getResources().getDisplayMetrics().density; int pixels = (int) (48 * scale + 0.5f); mivZoomLevel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); //ivZoomLevel.setTextAppearance(this, android.R.attr.textAppearanceLarge); mivZoomLevel.setWidth(pixels);/*from www.j a v a 2s . c o m*/ mivZoomLevel.setHeight(pixels); mivZoomLevel.setTextColor(Color.DKGRAY); mivZoomLevel.setBackgroundColor(Color.argb(50, 128, 128, 128)); //Color.LTGRAY R.drawable.ic_zoomlevel); mivZoomLevel.setGravity(Gravity.CENTER); mivZoomLevel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mivZoomLevel.setText("" + (int) Math.floor(mMap.getZoomLevel())); mivZoomIn.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMap.zoomIn(); } }); mivZoomOut.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMap.zoomOut(); } }); ivMark.setOnClickListener(new OnClickListener() { public void onClick(View v) { //TODO: onMark(); } }); final RelativeLayout.LayoutParams RightParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams1.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams1.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP rl.addView(mivZoomLevel, RightParams1); final RelativeLayout.LayoutParams RightParams4 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams4.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams4.addRule(RelativeLayout.ABOVE, R.drawable.ic_zoomlevel);//ALIGN_PARENT_TOP rl.addView(mivZoomIn, RightParams4); final RelativeLayout.LayoutParams RightParams3 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams3.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams3.addRule(RelativeLayout.ALIGN_PARENT_LEFT); RightParams3.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP rl.addView(ivMark, RightParams3); final RelativeLayout.LayoutParams RightParams2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RightParams2.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5); RightParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); RightParams2.addRule(RelativeLayout.BELOW, R.drawable.ic_zoomlevel);//R.drawable.ic_plus); rl.addView(mivZoomOut, RightParams2); setZoomInEnabled(mMap.canZoomIn()); setZoomOutEnabled(mMap.canZoomOut()); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
public void initialization(final boolean landscape, final boolean openAD, final Location lad, final String publisherId, final String keywords, final int requestInterval) { if (openAD) { // setVolumeControlStream(AudioManager.STREAM_MUSIC); AdManager.setPublisherId(publisherId); AdManager.setTestDevices(new String[] { "" }); AdManager.setAllowUseOfLocation(true); view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape); IHandler handler = view.getGameHandler(); RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(), handler.getHeight());//from www.ja v a2 s .c om if (landscape) { mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); } else { mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); } mainLayout.addView(view, mainParams); adview = new AdView(LGameAndroid2DActivity.this); if (keywords != null) { adview.setKeywords(keywords); } adview.setRequestInterval(requestInterval); adview.setGravity(Gravity.NO_GRAVITY); RelativeLayout rl = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); if (lad == Location.LEFT) { lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); } else if (lad == Location.RIGHT) { lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); } else if (lad == Location.TOP) { lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1); } else { lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); } // adview.setVisibility(View.GONE); visible = true; frameLayout.addView(mainLayout); rl.addView(adview, lp); frameLayout.addView(rl); } else { view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape); IHandler handler = view.getGameHandler(); RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(), handler.getHeight()); if (landscape) { mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); } else { mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); } mainLayout.addView(view, mainParams); frameLayout.addView(mainLayout); } if (setupSensors) { // ?? this.initSensors(); } if (view != null) { gameHandler = view.getGameHandler(); } }
From source file:com.adithyaupadhya.uimodule.roundcornerprogressbar.BaseRoundCornerProgressBar.java
private void setupReverse(LinearLayout layoutProgress) { RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams(); removeLayoutParamsRule(progressParams); if (isReverse) { progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // For support with RTL on API 17 or more if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) progressParams.addRule(RelativeLayout.ALIGN_PARENT_END); } else {/* w w w . j a va2s .c om*/ progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); // For support with RTL on API 17 or more if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) progressParams.addRule(RelativeLayout.ALIGN_PARENT_START); } layoutProgress.setLayoutParams(progressParams); }
From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java
private void initUI(final View view) { final FrameLayout layout = (FrameLayout) view.findViewById(R.id.layout_root); mPageNumberTextView = (TextView) view.findViewById(R.id.page_num_text_view); mLayoutName = layout.getTag().toString(); mDisablingOverlay = view.findViewById(R.id.disabling_overlay); mProgressBarHost = view.findViewById(R.id.progress_bar_host); mDisablingOverlay.setOnTouchListener(new View.OnTouchListener() { @Override/*from w ww .ja v a2 s .c o m*/ public boolean onTouch(View v, MotionEvent event) { return true; // ensure the user can't click buttons } }); mCropPageHost = (RelativeLayout) view.findViewById(R.id.page_crop_host); mCropImageBorder = view.findViewById(R.id.image_crop_border); mCropImageView = (com.edmodo.cropper.CropImageView) view.findViewById(R.id.image_crop_view); mCropImageView.setGuidelines(0); // off mCropImageBorder.setVisibility(View.GONE); mBlankPagePlaceholder = view.findViewById(R.id.blank_page_placeholder); mBlankPageSpinnerHost = (ContentLoadingRelativeLayout) view.findViewById(R.id.blank_page_progress_bar_host); if (mRemoveCropHelperMode) { View manualCropRoot = view.findViewById(R.id.manual_crop_root_layout); manualCropRoot.setVisibility(View.GONE); setCropBoxAndClose(); } else { mCropPageHost.postDelayed(new Runnable() { @Override public void run() { if (mIsActive) { if (mLayoutName.equals("layout-sw480dp-port") || mLayoutName.equals("layout-sw480dp-land")) { if (view.getWidth() < 540) { View buttonHost = view.findViewById(R.id.page_buttons_host); int[] location = new int[2]; buttonHost.getLocationInWindow(location); int buttonsLeft = location[0]; View pageNumText = view.findViewById(R.id.page_num_text_view); pageNumText.getLocationInWindow(location); int pageNumRight = location[0] + pageNumText.getWidth(); if (pageNumRight > buttonsLeft - 10) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) buttonHost .getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 0); } } } mCropImageBorder.setVisibility(View.VISIBLE); setPage(mCurrentPage); } } }, 200); // Extra delay to ensure that view has time to settle. post alone doesn't work. } getButtons(view); if (mDisablingOverlayShowing) { mDisablingOverlay.setVisibility(View.VISIBLE); } if (mSpinnerShowing) { mProgressBarHost.setVisibility(View.VISIBLE); } }
From source file:com.markupartist.sthlmtraveling.ui.view.TripView.java
public void updateViews() { this.setOrientation(VERTICAL); float scale = getResources().getDisplayMetrics().density; this.setPadding(getResources().getDimensionPixelSize(R.dimen.list_horizontal_padding), getResources().getDimensionPixelSize(R.dimen.list_vertical_padding), getResources().getDimensionPixelSize(R.dimen.list_horizontal_padding), getResources().getDimensionPixelSize(R.dimen.list_vertical_padding)); LinearLayout timeStartEndLayout = new LinearLayout(getContext()); TextView timeStartEndText = new TextView(getContext()); timeStartEndText.setText(DateTimeUtil.routeToTimeDisplay(getContext(), trip)); timeStartEndText.setTextColor(ContextCompat.getColor(getContext(), R.color.body_text_1)); timeStartEndText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); ViewCompat.setPaddingRelative(timeStartEndText, 0, 0, 0, (int) (2 * scale)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (RtlUtils.isRtl(Locale.getDefault())) { timeStartEndText.setTextDirection(View.TEXT_DIRECTION_RTL); }//from w w w . java2 s. c om } // Check if we have Realtime for start and or end. boolean hasRealtime = false; Pair<Date, RealTimeState> transitTime = trip.departsAt(true); if (transitTime.second != RealTimeState.NOT_SET) { hasRealtime = true; } else { transitTime = trip.arrivesAt(true); if (transitTime.second != RealTimeState.NOT_SET) { hasRealtime = true; } } // if (hasRealtime) { // ImageView liveDrawable = new ImageView(getContext()); // liveDrawable.setImageResource(R.drawable.ic_live); // ViewCompat.setPaddingRelative(liveDrawable, 0, (int) (2 * scale), (int) (4 * scale), 0); // timeStartEndLayout.addView(liveDrawable); // // AlphaAnimation animation1 = new AlphaAnimation(0.4f, 1.0f); // animation1.setDuration(600); // animation1.setRepeatMode(Animation.REVERSE); // animation1.setRepeatCount(Animation.INFINITE); // // liveDrawable.startAnimation(animation1); // } timeStartEndLayout.addView(timeStartEndText); LinearLayout startAndEndPointLayout = new LinearLayout(getContext()); TextView startAndEndPoint = new TextView(getContext()); BidiFormatter bidiFormatter = BidiFormatter.getInstance(RtlUtils.isRtl(Locale.getDefault())); startAndEndPoint.setText(String.format("%s %s", bidiFormatter.unicodeWrap(trip.fromStop().getName()), bidiFormatter.unicodeWrap(trip.toStop().getName()))); startAndEndPoint.setTextColor(getResources().getColor(R.color.body_text_1)); // Dark gray startAndEndPoint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (RtlUtils.isRtl(Locale.getDefault())) { startAndEndPoint.setTextDirection(View.TEXT_DIRECTION_RTL); } } ViewCompat.setPaddingRelative(startAndEndPoint, 0, (int) (4 * scale), 0, (int) (4 * scale)); startAndEndPointLayout.addView(startAndEndPoint); RelativeLayout timeLayout = new RelativeLayout(getContext()); LinearLayout routeChanges = new LinearLayout(getContext()); routeChanges.setGravity(Gravity.CENTER_VERTICAL); LinearLayout.LayoutParams changesLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); changesLayoutParams.gravity = Gravity.CENTER_VERTICAL; if (trip.hasAlertsOrNotes()) { ImageView warning = new ImageView(getContext()); warning.setImageResource(R.drawable.ic_trip_deviation); ViewCompat.setPaddingRelative(warning, 0, (int) (2 * scale), (int) (4 * scale), 0); routeChanges.addView(warning); } int currentTransportCount = 1; int transportCount = trip.getLegs().size(); for (Leg leg : trip.getLegs()) { if (!leg.isTransit() && transportCount > 3) { if (leg.getDistance() < 150) { continue; } } if (currentTransportCount > 1 && transportCount >= currentTransportCount) { ImageView separator = new ImageView(getContext()); separator.setImageResource(R.drawable.transport_separator); ViewCompat.setPaddingRelative(separator, 0, 0, (int) (2 * scale), 0); separator.setLayoutParams(changesLayoutParams); routeChanges.addView(separator); if (RtlUtils.isRtl(Locale.getDefault())) { ViewCompat.setScaleX(separator, -1f); } } ImageView changeImageView = new ImageView(getContext()); Drawable transportDrawable = LegUtil.getTransportDrawable(getContext(), leg); changeImageView.setImageDrawable(transportDrawable); if (RtlUtils.isRtl(Locale.getDefault())) { ViewCompat.setScaleX(changeImageView, -1f); } ViewCompat.setPaddingRelative(changeImageView, 0, 0, 0, 0); changeImageView.setLayoutParams(changesLayoutParams); routeChanges.addView(changeImageView); if (currentTransportCount <= 3) { String lineName = leg.getRouteShortName(); if (!TextUtils.isEmpty(lineName)) { TextView lineNumberView = new TextView(getContext()); lineNumberView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); RoundedBackgroundSpan roundedBackgroundSpan = new RoundedBackgroundSpan( LegUtil.getColor(getContext(), leg), Color.WHITE, ViewHelper.dipsToPix(getContext().getResources(), 4)); SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(lineName); sb.append(' '); sb.setSpan(roundedBackgroundSpan, 0, lineName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); lineNumberView.setText(sb); ViewCompat.setPaddingRelative(lineNumberView, (int) (5 * scale), (int) (1 * scale), (int) (2 * scale), 0); lineNumberView.setLayoutParams(changesLayoutParams); routeChanges.addView(lineNumberView); } } currentTransportCount++; } TextView durationText = new TextView(getContext()); durationText.setText(DateTimeUtil.formatDetailedDuration(getResources(), trip.getDuration() * 1000)); durationText.setTextColor(ContextCompat.getColor(getContext(), R.color.body_text_1)); durationText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); durationText.setTypeface(Typeface.DEFAULT_BOLD); timeLayout.addView(routeChanges); timeLayout.addView(durationText); RelativeLayout.LayoutParams durationTextParams = (RelativeLayout.LayoutParams) durationText .getLayoutParams(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { durationTextParams.addRule(RelativeLayout.ALIGN_PARENT_END); } else { durationTextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } durationText.setLayoutParams(durationTextParams); View divider = new View(getContext()); ViewGroup.LayoutParams dividerParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1); divider.setLayoutParams(dividerParams); this.addView(timeLayout); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) routeChanges.getLayoutParams(); params.height = LayoutParams.MATCH_PARENT; params.addRule(RelativeLayout.CENTER_VERTICAL); routeChanges.setLayoutParams(params); this.addView(startAndEndPointLayout); this.addView(timeStartEndLayout); if (mShowDivider) { this.addView(divider); } }
From source file:de.qspool.clementineremote.ui.fragments.PlayerFragment.java
public void showShowcase() { final ShowcaseView sv = new ShowcaseView.Builder(getActivity()).setStyle(R.style.ShowcaseTheme) .setTarget(new ActionViewTarget(getActivity(), ActionViewTarget.Type.HOME)) .setContentTitle(R.string.cm_player_home_title).setContentText(R.string.cm_player_home_content) .build();/* w w w . ja v a2s.c o m*/ sv.setButtonText(getString(R.string.cm_next)); sv.overrideButtonClick(new OnClickListener() { @Override public void onClick(View v) { switch (mShowcaseCounter) { case 0: sv.setShowcase(new ViewTarget(myPager), true); sv.setContentTitle(getString(R.string.cm_player_swipe_title)); sv.setContentText(getString(R.string.cm_player_swipe_content)); break; case 1: sv.setShowcase(new ViewTarget(mPlayerPageFragment.getImageArt()), true); sv.setContentTitle(getString(R.string.cm_player_lyrics_title)); sv.setContentText(getString(R.string.cm_player_lyrics_content)); break; case 2: sv.setButtonText(getString(R.string.cm_close)); sv.setShowcase(new ViewTarget(mBtnPlayPause), true); sv.setContentTitle(getString(R.string.cm_player_hold_pause_title)); sv.setContentText(getString(R.string.cm_player_hold_pause_content)); break; case 3: sv.hide(); break; } mShowcaseCounter++; } }); RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lps.addRule(RelativeLayout.ALIGN_PARENT_TOP); lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue(); lps.setMargins(margin, margin * 3, margin, margin); sv.setButtonPosition(lps); }
From source file:ti.modules.titanium.ui.widget.TiUIScrollableView.java
private RelativeLayout buildPagingControl(Context context) { RelativeLayout layout = new RelativeLayout(context); layout.setFocusable(false);/*from w w w . j ava2 s .com*/ layout.setFocusableInTouchMode(false); TiArrowView left = new TiArrowView(context); left.setVisibility(View.INVISIBLE); left.setId(PAGE_LEFT); left.setMinimumWidth(80); // TODO density? left.setMinimumHeight(80); left.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mEnabled) { movePrevious(); } } }); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); layout.addView(left, params); TiArrowView right = new TiArrowView(context); right.setLeft(false); right.setVisibility(View.INVISIBLE); right.setId(PAGE_RIGHT); right.setMinimumWidth(80); // TODO density? right.setMinimumHeight(80); right.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mEnabled) { moveNext(); } } }); params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); layout.addView(right, params); layout.setVisibility(View.GONE); return layout; }