List of usage examples for android.widget ScrollView getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:Main.java
public static void setScrollViewHeightBasedOnChild(ScrollView scrollView) { View child = scrollView.getChildAt(0); ViewGroup.LayoutParams params = (LayoutParams) scrollView.getLayoutParams(); params.height = child.getHeight();// ww w .ja va 2 s . c om scrollView.setLayoutParams(params); }
From source file:com.stu.zdy.weather.ui.fragment.InfoFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollview_info); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); int height = dm.heightPixels; scrollView.getLayoutParams().height = (height - ScreenUtils.getStatusHeight(getActivity())) * 586 / 640; TextView textView2 = (TextView) getActivity().findViewById(R.id.textview2); TextView textView3 = (TextView) getActivity().findViewById(R.id.textview3); String string = "<p>icon:<a href=\"http://azuresol.deviantart.com\">AzureSol</a>"; string = string + "<a href=\"http://creativecommons.org/licenses/by-sa/3.0/\"> ???</a></p>"; string = string + "<p>??:</p>"; string = string/* ww w. j a v a2 s. c o m*/ + "<p>Material Design Icons <a href=\"https://github.com/google/material-design-icons/releases/tag/1.0.0\">Github</a></p>"; string = string + "<p>MaterialDialog <a href=\"https://github.com/drakeet\">GitHub</a></p>"; string = string + "<p>Ldrawer <a href=\"https://github.com/keklikhasan/LDrawer\">GitHub</a></p>"; string = string + "<p>FloatingActionButton <a href=\"https://github.com/makovkastar/FloatingActionButton\">GitHub</a></p>"; string = string + "<p>materialish-progress-master <a href=\"https://github.com/pnikosis/materialish-progress\">GitHub</a></p>"; string = string + "<p>Java:json-lib <a href=\"http://json-lib.sourceforge.net\">GitHub</a></p>"; string = string + "<p>okhttp-utils <a href=\"https://github.com/hongyangAndroid/okhttp-utils\">GitHub</a></p>"; string = string + "<p>glide <a href=\"https://github.com/bumptech/glide\">GitHub</a></p>"; CharSequence charSequence = Html.fromHtml(string); textView2.setText(charSequence); textView2.setMovementMethod(LinkMovementMethod.getInstance()); String string2 = "<p><a href=\"http://weibo.com/u/3123268127\">?</a></p>"; CharSequence charSequence2 = Html.fromHtml(string2); textView3.setText(charSequence2); textView3.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.telegram.ui.ChangePhoneHelpActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); TLRPC.User user = UserConfig.getCurrentUser(); String value;//ww w. j av a 2 s . co m if (user != null && user.phone != null && user.phone.length() != 0) { value = PhoneFormat.getInstance().format("+" + user.phone); } else { value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } actionBar.setTitle(value); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new RelativeLayout(context); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); RelativeLayout relativeLayout = (RelativeLayout) fragmentView; ScrollView scrollView = new ScrollView(context); relativeLayout.addView(scrollView); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); scrollView.setLayoutParams(layoutParams3); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20)); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.phone_change); linearLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; imageView.setLayoutParams(layoutParams2); TextView textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setGravity(Gravity.CENTER_HORIZONTAL); //textView.setTextColor(0xff212121); try { textView.setText(AndroidUtilities .replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp))); } catch (Exception e) { FileLog.e("tmessages", e); textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)); } linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(56); textView.setLayoutParams(layoutParams2); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent) /*0xff4d83b3*/); textView.setText(LocaleController.getString("PhoneNumberChange", R.string.PhoneNumberChange)); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12)); textView.setBackground(context.getDrawable(R.drawable.list_selector)); linearLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.leftMargin = AndroidUtilities.dp(20); layoutParams2.rightMargin = AndroidUtilities.dp(20); layoutParams2.topMargin = AndroidUtilities.dp(46); textView.setLayoutParams(layoutParams2); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { presentFragment(new ChangePhoneActivity(), true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } }); return fragmentView; }
From source file:dynamite.zafroshops.app.MainActivity.java
public void updateView() { if (!AdsActive) { adView.setVisibility(View.GONE); ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView); if (scrollView != null) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); params.setMargins(0, 0, 0, 0); }//from w w w .j a v a 2s . c om } else { adView.setVisibility(View.VISIBLE); } }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragDown(int start) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w . j a v a2s .co m*/ int height = size.y; if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sliderStartDrag = height - start - params.height; sliderHeightStart = params.height; } }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragDragging(int whereY) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww.ja v a 2s . co m int height = size.y; if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if ((height - whereY - sliderStartDrag) > 0) { params.height = height - whereY - sliderStartDrag; } else { params.height = 0; } sv.setLayoutParams(params); } }
From source file:com.openatk.planting.MainActivity.java
private void SliderShrink() { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*www . ja v a 2 s .co m*/ int oneThirdHeight = (size.y / 3); if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if (sliderPosition == 1) { //Middle -> Small DropDownAnim an = new DropDownAnim(sv, params.height, 0); an.setDuration(300); sv.startAnimation(an); sliderPosition = 0; } else if (sliderPosition == 2) { //Fullscreen -> Middle if has notes //Fullscreen -> Small if no notes if (false) { DropDownAnim an = new DropDownAnim(sv, params.height, oneThirdHeight); an.setDuration(300); sv.startAnimation(an); sliderPosition = 1; } else { DropDownAnim an = new DropDownAnim(sv, params.height, 0); an.setDuration(300); sv.startAnimation(an); sliderPosition = 0; } } sv.setLayoutParams(params); } }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragUp(int whereY) { //Slider done dragging snap to 1 of 3 positions Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);/* w ww .ja va2 s.co m*/ int oneThirdHeight = size.y / 3; if (whereY < oneThirdHeight) { //Fullscreen Log.d("SliderDragUp", "fullscreen"); } else if (whereY < oneThirdHeight * 2) { //Middle Log.d("SliderDragUp", "middle"); } else { //Closed Log.d("SliderDragUp", "closed"); } //Find end height if (fragmentEditField != null) { Log.d("slider", "not null"); ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if (params.height > sliderHeightStart) { //Make bigger SliderGrow(); } else { //Make smaller SliderShrink(); } } else { Log.d("slider", "null"); } }
From source file:com.openatk.planting.MainActivity.java
private void SliderGrow() { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww . jav a2 s. co m int oneThirdHeight = size.y / 3; int actionBarHeight = 10; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } if (fragmentEditField != null) { RelativeLayout relAdd = (RelativeLayout) fragmentEditField.getView().findViewById(R.id.slider_layMenu); RelativeLayout relBottomBar = (RelativeLayout) fragmentEditField.getView() .findViewById(R.id.edit_field_layInfo3); Log.d("layMenu:", Integer.toString(relAdd.getHeight())); ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if (sliderPosition == 0) { //Small -> Middle DropDownAnim an = new DropDownAnim(sv, params.height, oneThirdHeight); an.setDuration(300); sv.startAnimation(an); sliderPosition = 1; } else if (sliderPosition == 1) { //Middle -> Fullscreen DropDownAnim an = new DropDownAnim(sv, params.height, (fragMap.getView().getHeight() - relAdd.getHeight() - relBottomBar.getHeight())); Log.d("fullslider", "Full slider" + Integer.toString(relBottomBar.getHeight())); an.setDuration(300); sv.startAnimation(an); sliderPosition = 2; } sv.setLayoutParams(params); } }
From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java
private void setDetailScrollViewHeight() { final Point displaySize = UIUtils.getDisplaySize(mActivity); final TextView nameLbl = (TextView) mDetailDialog.findViewById(R.id.name); final TextView priceLbl = (TextView) mDetailDialog.findViewById(R.id.price); final ScrollView scrollView = (ScrollView) mDetailDialog.findViewById(R.id.scroll_view); final LinearLayout valueContainer = (LinearLayout) mDetailDialog.findViewById(R.id.value_container); final Button dismissBtn = (Button) mDetailDialog.findViewById(R.id.dismiss); int maxPopupHeight = (int) Math.floor(displaySize.y * 0.75); int desiredWidth = MeasureSpec.makeMeasureSpec(nameLbl.getWidth(), MeasureSpec.AT_MOST); nameLbl.measure(desiredWidth, 0);//from w w w. j a va 2s . co m int nameLblHeight = nameLbl.getMeasuredHeight(); int priceLblHeight = 0; if (priceLbl.getVisibility() == View.VISIBLE) { priceLbl.measure(desiredWidth, 0); priceLblHeight = priceLbl.getMeasuredHeight(); } valueContainer.measure(desiredWidth, 0); int valueContainerHeight = valueContainer.getMeasuredHeight(); dismissBtn.measure(desiredWidth, 0); int dismissBtnHeight = dismissBtn.getMeasuredHeight(); int maxScrollViewHeight = maxPopupHeight - nameLblHeight - priceLblHeight - valueContainerHeight - dismissBtnHeight; ViewGroup.LayoutParams params = scrollView.getLayoutParams(); scrollView.measure(desiredWidth, 0); params.height = scrollView.getMeasuredHeight(); if (maxScrollViewHeight > 0 && params.height > maxScrollViewHeight) { params.height = maxScrollViewHeight; } scrollView.setLayoutParams(params); scrollView.requestLayout(); }