List of usage examples for android.content.res Resources getDisplayMetrics
public DisplayMetrics getDisplayMetrics()
From source file:net.eledge.android.europeana.gui.activity.HomeActivity.java
public void setLocale(String lang) { Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = new Locale(lang); res.updateConfiguration(conf, dm);/* w ww .ja v a2 s .c om*/ Intent refresh = new Intent(this, HomeActivity.class); startActivity(refresh); }
From source file:oly.netpowerctrl.main.MainActivity.java
private void assignContentView() { setContentView(R.layout.activity_main); boolean has_two_panes = getResources().getBoolean(R.bool.has_two_panes); LayoutInflater l = LayoutInflater.from(this); FragmentUtils.unloadFragment(this, "group"); FrameLayout layout = (FrameLayout) findViewById(R.id.content); layout.removeAllViews();/*from w w w.j a v a 2 s.c om*/ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); View v = l.inflate(!has_two_panes ? R.layout.content_frame_with_sliding_group_list : R.layout.content_frame_with_group_list, null); layout.addView(v, lp); FragmentUtils.loadFragment(this, GroupListFragment.class.getName(), R.id.group_list_fragment, "group"); FragmentUtils.changeToFragment(this, ExecutablesFragment.class.getName(), "outlets", null); if (!has_two_panes) { panes = (SlidingPaneLayout) findViewById(R.id.drawerLayout); Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 240, r.getDisplayMetrics()); panes.setParallaxDistance((int) px / 2); panes.setCoveredFadeColor(0); panes.setSliderFadeColor(0); panes.setShadowResourceLeft(R.drawable.drawer_shadow_left); panes.setShadowResourceRight(R.drawable.drawer_shadow); panes.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { } @Override public void onPanelOpened(View panel) { } @Override public void onPanelClosed(View panel) { } }); //if (panes.isSlideable()) panes.openPane(); } if (SharedPrefs.getInstance().isBackground()) { Drawable d = LoadStoreIconData.loadBackgroundBitmap(); findViewById(android.R.id.content).setBackground(d); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); setSupportActionBar(toolbar); }
From source file:org.openmrs.mobile.activities.fragments.FormPageFragment.java
void addSection(Section section, LinearLayout parent) { LinearLayout sectionLL = new LinearLayout(getActivity()); sectionLL.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); //get resources Resources r = getActivity().getResources(); float pxLeftMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxTopMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxRightMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); float pxBottomMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); layoutParams.setMargins(Math.round(pxLeftMargin), Math.round(pxTopMargin), Math.round(pxRightMargin), Math.round(pxBottomMargin)); parent.addView(sectionLL);// w w w. j a va 2 s .c o m TextView tv = new TextView(getActivity()); tv.setText(section.getLabel()); tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tv.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary)); sectionLL.addView(tv, layoutParams); for (Question question : section.getQuestions()) { addQuestion(question, sectionLL); } }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);//from w w w.j a v a 2 s .com RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(imageParams); // imageView.setAdjustViewBounds(true); Resources r = context.getResources(); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); TextView descriptionView = new TextView(context); descriptionView.setId(2); descriptionView.setPadding(padding, 0, padding, padding); descriptionView.setText(description); descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10)); descriptionView.setTextColor(Color.WHITE); RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId()); carouselView.addView(descriptionView, descParams); TextView titleView = new TextView(context); titleView.setText(title); titleView.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId()); titleView.setLayoutParams(titleParams); titleView.setTextColor(Color.WHITE); titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0)); titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); carouselView.addView(titleView); }
From source file:de.vanita5.twittnuker.loader.support.TileImageLoader.java
public TileImageLoader(final Context context, final DownloadListener listener, final long accountId, final Uri uri) { super(context); mHandler = new Handler(); mAccountId = accountId;//from ww w . j a v a 2 s . c o m mUri = uri; mListener = listener; final TwittnukerApplication app = TwittnukerApplication.getInstance(context); mDownloader = app.getFullImageDownloader(); mDiskCache = app.getFullDiskCache(); final Resources res = context.getResources(); final DisplayMetrics dm = res.getDisplayMetrics(); mFallbackSize = Math.max(dm.heightPixels, dm.widthPixels); }
From source file:org.getlantern.firetweet.loader.support.TileImageLoader.java
public TileImageLoader(final Context context, final DownloadListener listener, final long accountId, final Uri uri) { super(context); mHandler = new Handler(); mAccountId = accountId;//from ww w . j a v a 2 s .com mUri = uri; mListener = listener; final FiretweetApplication app = FiretweetApplication.getInstance(context); mDownloader = app.getFullImageDownloader(); mDiskCache = app.getFullDiskCache(); final Resources res = context.getResources(); final DisplayMetrics dm = res.getDisplayMetrics(); mFallbackSize = Math.max(dm.heightPixels, dm.widthPixels); }
From source file:org.mariotaku.twidere.loader.support.TileImageLoader.java
public TileImageLoader(final Context context, final DownloadListener listener, final long accountId, final Uri uri) { super(context); mHandler = new Handler(); mAccountId = accountId;/* w ww .j av a 2s. co m*/ mUri = uri; mListener = listener; final TwidereApplication app = TwidereApplication.getInstance(context); mDownloader = app.getFullImageDownloader(); mDiskCache = app.getFullDiskCache(); final Resources res = context.getResources(); final DisplayMetrics dm = res.getDisplayMetrics(); mFallbackSize = Math.max(dm.heightPixels, dm.widthPixels); }
From source file:com.anykey.balala.activity.BaseActivity.java
@Override public Resources getResources() { Resources res = super.getResources(); Configuration config = new Configuration(); config.setToDefaults();//from w w w . jav a 2s .c o m res.updateConfiguration(config, res.getDisplayMetrics()); return res; }
From source file:de.vanita5.twittnuker.fragment.BaseFiltersFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); final View lv = view.findViewById(android.R.id.list); final Resources res = getResources(); final float density = res.getDisplayMetrics().density; final int padding = (int) density * 16; lv.setId(android.R.id.list);//from w w w . ja va 2 s.co m lv.setPadding(padding, 0, padding, 0); return view; }
From source file:com.anykey.balala.activity.BaseActivity.java
@Override protected void onResume() { //?/* w ww. j a v a 2s . c o m*/ Resources resource = getResources(); Configuration c = resource.getConfiguration(); c.fontScale = 1.0f; resource.updateConfiguration(c, resource.getDisplayMetrics()); super.onResume(); TCAgent.onResume(this); MobclickAgent.onResume(this); AppsFlyerLib.onActivityResume(this); }