List of usage examples for android.view View setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.miz.utils.ViewUtils.java
public static void setLayoutParamsForDetailsEmptyView(Context context, View layout, ImageView background, ObservableScrollView scrollView, ViewTreeObserver.OnGlobalLayoutListener listener) { if (!MizLib.isPortrait(context)) { // Let's set the size of the empty view on the scroll container View empty = layout.findViewById(R.id.empty_view); if (empty == null) return; // First, we get the height of the background image, since that // fills the available screen estate in its entirety int fullHeight = background.getHeight(); // Then we get the content height - this is how much of the content // will be shown on the screen at a minimum int contentHeight = context.getResources().getDimensionPixelSize(R.dimen.content_details_main_height); // Finally we set the empty view to fill the width and have a height // that fills the gap between the full height and content height empty.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullHeight - contentHeight)); }//from www . j a v a 2s . c om // Remove the ViewTreeObserver when we're done :-) MizLib.removeViewTreeObserver(scrollView.getViewTreeObserver(), listener); }
From source file:com.canyinghao.canadapter.CanRVFragmentAdapter.java
@Override public final FragmentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = new FrameLayout(parent.getContext()); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); int id = Math.abs(new Random().nextInt()); if (parent.getContext() instanceof Activity) { while (((Activity) parent.getContext()).getWindow().getDecorView().findViewById(id) != null) { id = Math.abs(new Random().nextInt()); }/* w w w. j a va2s . com*/ } view.setId(id); mIds.add(id); return new FragmentViewHolder(view); }
From source file:com.bamobile.fdtks.util.Tools.java
public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) return;/*from ww w.j a v a 2 s .c o m*/ int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT)); view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); listView.requestLayout(); }
From source file:com.google.android.apps.iosched2.ui.WhatsOnFragment.java
private void refresh() { mMessageHandler.removeCallbacks(mCountdownRunnable); mRootView.removeAllViews();//from w ww .j a va 2 s. c o m final long currentTimeMillis = UIUtils.getCurrentTime(getActivity()); // Show Loading... and load the view corresponding to the current state if (currentTimeMillis < UIUtils.getConferenceStart()) { setupBefore(); } else if (currentTimeMillis > UIUtils.getConferenceEnd()) { setupAfter(); } else { setupDuring(); } if (!UIUtils.isHoneycombTablet(getActivity())) { View separator = new View(getActivity()); separator.setLayoutParams(new ViewGroup.LayoutParams(1, ViewGroup.LayoutParams.FILL_PARENT)); separator.setBackgroundResource(R.drawable.whats_on_separator); mRootView.addView(separator); View view = getActivity().getLayoutInflater().inflate(R.layout.whats_on_stream, mRootView, false); view.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { AnalyticsUtils.getInstance(getActivity()).trackEvent("Home Screen Dashboard", "Click", "Realtime Stream", 0); //Intent intent = new Intent(getActivity(), TagStreamActivity.class); Intent intent = new Intent(getActivity(), Setup.TagStreamActivityClass); startActivity(intent); } }); mRootView.addView(view); } }
From source file:com.goliathonline.android.kegbot.ui.WhatsOnFragment.java
private void refresh() { mRootView.removeAllViews();/*from w w w . j a va 2 s .co m*/ if (false) { //!UIUtils.isHoneycombTablet(getActivity()) View separator = new View(getActivity()); separator.setLayoutParams(new ViewGroup.LayoutParams(1, ViewGroup.LayoutParams.FILL_PARENT)); separator.setBackgroundResource(R.drawable.whats_on_separator); mRootView.addView(separator); View view = getActivity().getLayoutInflater().inflate(R.layout.whats_on_stream, mRootView, false); view.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { AnalyticsUtils.getInstance(getActivity()).trackEvent("Home Screen Dashboard", "Click", "Realtime Stream", 0); Intent intent = new Intent(getActivity(), TagStreamActivity.class); startActivity(intent); } }); mRootView.addView(view); } }
From source file:com.google.android.apps.iosched.ui.WhatsOnFragment.java
private void refresh() { mMessageHandler.removeCallbacks(mCountdownRunnable); mRootView.removeAllViews();/*from w ww . j av a 2 s .c o m*/ final long currentTimeMillis = UIUtils.getCurrentTime(getActivity()); // Show Loading... and load the view corresponding to the current state if (currentTimeMillis < UIUtils.CONFERENCE_START_MILLIS) { setupBefore(); } else if (currentTimeMillis > UIUtils.CONFERENCE_END_MILLIS) { setupAfter(); } else { setupDuring(); } if (!UIUtils.isHoneycombTablet(getActivity())) { View separator = new View(getActivity()); separator.setLayoutParams(new ViewGroup.LayoutParams(1, ViewGroup.LayoutParams.FILL_PARENT)); separator.setBackgroundResource(R.drawable.whats_on_separator); mRootView.addView(separator); View view = getActivity().getLayoutInflater().inflate(R.layout.whats_on_stream, mRootView, false); view.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { AnalyticsUtils.getInstance(getActivity()).trackEvent("Home Screen Dashboard", "Click", "Realtime Stream", 0); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(REGISTER_URI); startActivity(intent); } }); mRootView.addView(view); } }
From source file:com.nadmm.airports.tfr.TfrListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); final ListView listView = getListView(); View footer = inflater.inflate(R.layout.tfr_list_footer_view, listView, false); footer.setLayoutParams( new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT)); TextView tv = (TextView) footer.findViewById(R.id.tfr_warning_text); tv.setText("Depicted TFR data may not be a complete listing. Pilots should not use " + "the information for flight planning purposes. For the latest information, " + "call your local Flight Service Station at 1-800-WX-BRIEF."); listView.addFooterView(footer, null, false); listView.setFooterDividersEnabled(true); return view;/*w w w .j av a 2s . c o m*/ }
From source file:com.android.inputmethod.keyboard.emoji.EmojiLayoutParams.java
public void setCategoryPageIdViewProperties(final View v) { final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) v.getLayoutParams(); lp.height = mEmojiCategoryPageIdViewHeight; v.setLayoutParams(lp); }
From source file:com.nkana.app.fragment.PlacesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View rootView = inflater.inflate(R.layout.fragment_places, container, false); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); listview = (ListView) rootView.findViewById(R.id.listview); preferences = getActivity().getSharedPreferences(IConstants.AUTH_TOKEN, getActivity().MODE_PRIVATE); authKey = preferences.getString(IConstants.AUTHORIZATION, null); // getGroupsList(); return rootView; }
From source file:com.example.onepointnews.fragment.SlidRightFragment.java
void initParams(View view) { float scale = this.getResources().getDisplayMetrics().density; DisplayMetrics dm = new DisplayMetrics(); this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); view.setLayoutParams(new LayoutParams(dm.widthPixels - (int) (0.0 * scale + 0.5f), dm.heightPixels)); }