List of usage examples for android.widget LinearLayout getMeasuredHeight
public final int getMeasuredHeight()
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 ww w . j a v a 2 s . c o 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(); }
From source file:com.thingsee.tracker.MainActivity.java
@SuppressLint("InflateParams") private Marker makeMarkerToMap(LatLng latLng, boolean visible, boolean alarmActive, String name, double timeStamp, double accuracy) { String snippet;/*from ww w. ja v a 2 s . c om*/ LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout tv = (LinearLayout) inflater.inflate(R.layout.tracker_map_marker, null, false); TextView trackerName = (TextView) tv.findViewById(R.id.tracker_name); trackerName.setText(name); ImageView image2 = (ImageView) tv.findViewById(R.id.tracker_marker_icon); if (alarmActive) { image2.setColorFilter(mResources.getColor(R.color.red)); trackerName.setTextColor(mResources.getColor(R.color.white_effect)); } else { image2.setColorFilter(mResources.getColor(R.color.dark_blue)); trackerName.setTextColor(mResources.getColor(R.color.white_effect)); } tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.setDrawingCacheEnabled(true); tv.buildDrawingCache(); Bitmap bm = tv.getDrawingCache(); tv = null; if (accuracy != -1) { snippet = String.format(mResources.getString(R.string.tracker_accuracy), accuracy); } else { snippet = String.format(mResources.getString(R.string.tracker_accuracy), 0.0f); } if (timeStamp != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, timeStamp); snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " " + timeStampText; } else { snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " - "; } return mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(bm)) .visible(visible).title(name).snippet(snippet)); }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
@Override public void onClick(View v) { // Toast.makeText(this,"clicked ..."+v.getId(),3000).show(); ImageView button = null;//from ww w . j av a2s . c o m LinearLayout l = null; int grid = 0; int testid = 0; boolean buttonfound = false; int id = v.getId(); if (id == R.id.download_header || id == R.id.btn_download_toggle) { if (total_download_archive_records > 0) { buttonfound = true; } grid = R.id.agggregate_test1_grid; testid = TestResult.DOWNLOAD_TEST_ID; l = (LinearLayout) findViewById(R.id.download_content); button = (ImageView) findViewById(R.id.btn_download_toggle); } if (id == R.id.upload_header || id == R.id.btn_upload_toggle) { if (total_upload_archive_records > 0) { buttonfound = true; } grid = R.id.agggregate_test2_grid; testid = TestResult.UPLOAD_TEST_ID; l = (LinearLayout) findViewById(R.id.upload_content); button = (ImageView) findViewById(R.id.btn_upload_toggle); } if (id == R.id.latency_header || id == R.id.btn_latency_toggle) { if (total_latency_archive_records > 0) { buttonfound = true; } grid = R.id.agggregate_test3_grid; testid = TestResult.LATENCY_TEST_ID; l = (LinearLayout) findViewById(R.id.latency_content); button = (ImageView) findViewById(R.id.btn_latency_toggle); } if (id == R.id.packetloss_header || id == R.id.btn_packetloss_toggle) { if (total_packetloss_archive_records > 0) { buttonfound = true; } grid = R.id.agggregate_test4_grid; testid = TestResult.PACKETLOSS_TEST_ID; l = (LinearLayout) findViewById(R.id.packetloss_content); button = (ImageView) findViewById(R.id.btn_packetloss_toggle); } if (id == R.id.jitter_header || id == R.id.btn_jitter_toggle) { if (total_jitter_archive_records > 0) { buttonfound = true; } grid = R.id.agggregate_test5_grid; testid = TestResult.JITTER_TEST_ID; l = (LinearLayout) findViewById(R.id.jitter_content); button = (ImageView) findViewById(R.id.btn_jitter_toggle); } // actions if (buttonfound) { if (l.getVisibility() == View.INVISIBLE) { button.setBackgroundResource(R.drawable.btn_up); button.setContentDescription(getString(R.string.close_panel)); // graphHandler1.update(); l.measure(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); target_height = l.getMeasuredHeight(); clearGrid(grid); loadDownloadGrid(testid, grid, 0, 5); l.getLayoutParams().height = 0; l.setVisibility(View.VISIBLE); ResizeAnimation animation = null; animation = new ResizeAnimation(l, target_height, 0, false); animation.setDuration(500); animation.setFillEnabled(true); animation.setFillAfter(true); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } }); l.startAnimation(animation); } else { ResizeAnimation animation = null; int required_height = l.getMeasuredHeight(); animation = new ResizeAnimation(l, 0, target_height, false); animation.setDuration(500); animation.setFillEnabled(true); animation.setFillAfter(true); MyAnimationListener animationListener = new MyAnimationListener(); animationListener.setView(l); animation.setAnimationListener(animationListener); l.startAnimation(animation); button.setBackgroundResource(R.drawable.btn_down); button.setContentDescription(getString(R.string.open_panel)); } } }