List of usage examples for android.content.res Resources getDimension
public float getDimension(@DimenRes int id) throws NotFoundException
From source file:com.tbse.mywearapplication.WatchFaceDrawer.java
WatchFaceDrawer(Context context) { Resources res = context.getResources(); // initialize your resources mHourOuterOffset = res.getDimension(R.dimen.hour_outer_offset); mMinuteOuterOffset = res.getDimension(R.dimen.minute_outer_offset); mSecondOuterOffset = res.getDimension(R.dimen.second_outer_offset); mPreviewSquareRadius = res.getDimension(R.dimen.watchface_preview_square_radius); mBackgroundPaint = new Paint(); mBackgroundPaint.setColor(ContextCompat.getColor(context, R.color.watchface_background)); mSecondHandPaint = new Paint(); mSecondHandPaint.setColor(ContextCompat.getColor(context, R.color.second_hand)); mSecondHandPaint.setStrokeWidth(res.getDimension(R.dimen.seconds_hand_stroke)); mSecondHandPaint.setAntiAlias(true); mSecondHandPaint.setStrokeCap(Paint.Cap.ROUND); mMinuteHandPaint = new Paint(mSecondHandPaint); mMinuteHandPaint.setColor(ContextCompat.getColor(context, R.color.minute_hand)); mMinuteHandPaint.setStrokeWidth(res.getDimension(R.dimen.minute_hand_stroke)); mHourHandPaint = new Paint(mSecondHandPaint); mHourHandPaint.setColor(ContextCompat.getColor(context, R.color.hour_hand)); mHourHandPaint.setStrokeWidth(res.getDimension(R.dimen.hour_hand_stroke)); textPaint = new Paint(); ambientTextPaint = new Paint(); textPaint.setColor(ContextCompat.getColor(context, R.color.black)); ambientTextPaint.setColor(ContextCompat.getColor(context, R.color.white)); }
From source file:com.google.android.leanbackjank.ui.MainFragment.java
private void loadVideoData(int categoryCount, int entriesPerCat, boolean disableShadows, boolean useSingleBitmap, int cardWidth, int cardHeight) { ListRowPresenter listRowPresenter = new ListRowPresenter() { @Override//from w w w .j a va 2 s.co m protected ShadowOverlayHelper.Options createShadowOverlayOptions() { Resources res = getResources(); ShadowOverlayHelper.Options options = new ShadowOverlayHelper.Options(); options.dynamicShadowZ(res.getDimension(R.dimen.shadow_unfocused_z), res.getDimension(R.dimen.shadow_focused_z)); return options; } }; listRowPresenter.setShadowEnabled(!disableShadows); // see b/64451726, leanback bug causes child rounded corner is incorrectly disabled when // shadow is disabled. To make the test data consistent and comparable, by default treat // the rounded corner option same as shadow option. boolean disableRoundedCorner = disableShadows; listRowPresenter.enableChildRoundedCorners(!disableRoundedCorner); mRowsAdapter = new ArrayObjectAdapter(listRowPresenter); HashMap<String, List<VideoInfo>> data = VideoProvider.buildMedia(categoryCount, entriesPerCat, cardWidth, cardHeight, getActivity(), useSingleBitmap); CardPresenter cardPresenter = new CardPresenter(cardWidth, cardHeight); int i = 0; for (Map.Entry<String, List<VideoInfo>> entry : data.entrySet()) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); for (VideoInfo videoInfo : entry.getValue()) { listRowAdapter.add(videoInfo); } HeaderItem header = new HeaderItem(i++, entry.getKey()); mRowsAdapter.add(new ListRow(header, listRowAdapter)); } ArrayObjectAdapter settingsListAdapter = new ArrayObjectAdapter(new GridItemPresenter()); for (int j = 0; j < entriesPerCat; j++) { settingsListAdapter.add("Settings " + j); } HeaderItem settingsHeader = new HeaderItem(i++, "Settings"); mRowsAdapter.add(new ListRow(settingsHeader, settingsListAdapter)); setAdapter(mRowsAdapter); }
From source file:org.mindframes.latestfm.ui.views.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); Resources resources = getResources(); TEXT_SIZE = resources.getDimension(R.dimen.small_text); HORIZONTAL_PADDING = (int) resources.getDimension(R.dimen.activity_half_horizontal_margin); VERTICAL_PADDING = (int) resources.getDimension(R.dimen.activity_vertical_margin); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);/* ww w .j a v a 2 s. c om*/ mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
From source file:com.webarch.srmobile.activities.sub.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w ww . j a v a2 s. c o m*/ */ protected TextView createDefaultTabView(Context context) { Text text = new Text(context, null); text.setGravity(Gravity.CENTER); Resources resources = getResources(); text.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.text_2)); text.setTextColor(resources.getColor(R.color.dark)); int border1 = (int) resources.getDimension(R.dimen.border_1), border2 = (int) resources.getDimension(R.dimen.border_2); text.setPadding(border1, border2, border1, border2); return text; }
From source file:com.android.gallery3d.gadget.WidgetConfigure.java
private void setChoosenPhoto(final Intent data) { AsyncTask.execute(new Runnable() { @Override//from ww w . jav a 2 s. c o m public void run() { Resources res = getResources(); float width = res.getDimension(R.dimen.appwidget_width); float height = res.getDimension(R.dimen.appwidget_height); // We try to crop a larger image (by scale factor), but there is still // a bound on the binder limit. float scale = Math.min(WIDGET_SCALE_FACTOR, MAX_WIDGET_SIDE / Math.max(width, height)); int widgetWidth = Math.round(width * scale); int widgetHeight = Math.round(height * scale); File cropSrc = new File(getCacheDir(), "crop_source.png"); File cropDst = new File(getCacheDir(), "crop_dest.png"); mPickedItem = data.getData(); if (!copyUriToFile(mPickedItem, cropSrc)) { setResult(Activity.RESULT_CANCELED); finish(); return; } mCropSrc = FileProvider.getUriForFile(WidgetConfigure.this, "com.android.gallery3d.fileprovider", new File(cropSrc.getAbsolutePath())); mCropDst = FileProvider.getUriForFile(WidgetConfigure.this, "com.android.gallery3d.fileprovider", new File(cropDst.getAbsolutePath())); Intent request = new Intent(CropActivity.CROP_ACTION).putExtra(CropExtras.KEY_OUTPUT_X, widgetWidth) .putExtra(CropExtras.KEY_OUTPUT_Y, widgetHeight) .putExtra(CropExtras.KEY_ASPECT_X, widgetWidth) .putExtra(CropExtras.KEY_ASPECT_Y, widgetHeight) .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true).putExtra(CropExtras.KEY_SCALE, true) .putExtra(CropExtras.KEY_RETURN_DATA, false).setDataAndType(mCropSrc, "image/*") .addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); request.putExtra(MediaStore.EXTRA_OUTPUT, mCropDst); request.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, mCropDst)); startActivityForResult(request, REQUEST_CROP_IMAGE); } }); }
From source file:com.openvehicles.OVMS.ui.utils.DemoClusterOptionsProvider.java
public DemoClusterOptionsProvider(Resources resources) { baseBitmaps = new Bitmap[res.length]; for (int i = 0; i < res.length; i++) { baseBitmaps[i] = BitmapFactory.decodeResource(resources, res[i]); }// w w w . jav a2 s . co m paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTextSize(resources.getDimension(R.dimen.text_size)); }
From source file:com.openatk.rockapp.MyClusterOptionsProvider.java
public MyClusterOptionsProvider(Resources resources) { baseBitmaps = new Bitmap[res.length]; for (int i = 0; i < res.length; i++) { baseBitmaps[i] = BitmapFactory.decodeResource(resources, res[i]); }//from ww w. ja v a2 s. c om paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTextSize(resources.getDimension(R.dimen.text_size)); }
From source file:com.sbgapps.scoreit.fragments.ScoreGraphFragment.java
public void update() { final GameHelper gameHelper = getGameHelper(); final int lapCnt = gameHelper.getLaps().size(); mChartView.reset();// ww w . j a v a2 s . com mChartView.setVisibility((0 == lapCnt) ? View.INVISIBLE : View.VISIBLE); if (0 == lapCnt) return; final Resources resources = getActivity().getResources(); int score; for (int player = 0; player < gameHelper.getPlayerCount(); player++) { LineSet set = new LineSet(); set.setLineColor(gameHelper.getPlayerColor(player)); set.setLineThickness(resources.getDimension(R.dimen.line_thickness)); set.setDots(true); set.setDotsColor(gameHelper.getPlayerColor(player)); set.addPoint("", 0); score = 0; for (Lap lap : gameHelper.getLaps()) { score += lap.getScore(player); set.addPoint("", score); } mChartView.addData(set); } mChartView.show(new Animation().setEasing(new CubicEaseOut()).setOverlap(0.8f).setStartPoint(-1f, 0f) .setAlpha(1).setDuration(getActivity().getResources().getInteger(R.integer.anim_medium_time))); }
From source file:com.andryr.musicplayer.fragments.AlbumListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_album_list, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.list_view); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Resources res = getActivity().getResources(); float screenWidth = display.getWidth(); float itemWidth = res.getDimension(R.dimen.album_grid_item_width); mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), Math.round(screenWidth / itemWidth))); int artworkSize = res.getDimensionPixelSize(R.dimen.art_size); mAdapter = new AlbumListAdapter(getActivity(), artworkSize, artworkSize); mAdapter.setOnItemClickListener(mOnItemClickListener); mRecyclerView.setAdapter(mAdapter);/*ww w . j a v a 2 s .c o m*/ mFastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller); mFastScroller.setShowBubble(mShowScrollerBubble); mFastScroller.setSectionIndexer(mAdapter); mFastScroller.setRecyclerView(mRecyclerView); return rootView; }
From source file:simon.databasedemo.DemoClusterOptionsProvider.java
public DemoClusterOptionsProvider(Resources resources) { baseBitmaps = new Bitmap[res.length]; for (int i = 0; i < res.length; i++) { baseBitmaps[i] = BitmapFactory.decodeResource(resources, res[i]); }//w w w .jav a 2 s .c om paint.setColor(Color.WHITE); paint.setTextAlign(Paint.Align.CENTER); paint.setTextSize(resources.getDimension(R.dimen.text_size)); }