Here are the examples of the java api class android.view.ViewGroup.LayoutParams taken from open source projects.
1. RxSwipeRefreshLayoutTestActivity#onCreate()
Project: RxBinding
File: RxSwipeRefreshLayoutTestActivity.java
File: RxSwipeRefreshLayoutTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); swipeRefreshLayout = new SwipeRefreshLayout(this); swipeRefreshLayout.setId(R.id.swipe_refresh_layout); swipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) { handler.removeCallbacks(stopRefreshing); handler.postDelayed(stopRefreshing, 300); } return false; } }); ScrollView scrollView = new ScrollView(this); LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT); swipeRefreshLayout.addView(scrollView, scrollParams); FrameLayout emptyView = new FrameLayout(this); LayoutParams emptyParams = new LayoutParams(MATCH_PARENT, 100000); scrollView.addView(emptyView, emptyParams); setContentView(swipeRefreshLayout); }
2. RxNestedScrollViewTestActivity#onCreate()
Project: RxBinding
File: RxNestedScrollViewTestActivity.java
File: RxNestedScrollViewTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ScrollView scrollView = new ScrollView(this); nestedScrollView = new NestedScrollView(this); emptyView = new FrameLayout(this); LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT); LayoutParams emptyParams = new LayoutParams(50000, 50000); nestedScrollView.addView(emptyView, emptyParams); scrollView.addView(nestedScrollView, scrollParams); setContentView(scrollView, scrollParams); }
3. AspectRatioMeasureTest#testExactly()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testExactly() { // width mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); }
4. AspectRatioMeasureTest#testNoAspectRatio()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testNoAspectRatio() { // width mSpec.width = makeMeasureSpec(410, UNSPECIFIED); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 0, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, UNSPECIFIED), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, UNSPECIFIED); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 0, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, UNSPECIFIED), mSpec.height); }
5. AspectRatioMeasureTest#testAspectRatio()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testAspectRatio() { // width mSpec.width = makeMeasureSpec(410, UNSPECIFIED); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(460, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, UNSPECIFIED); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(210, EXACTLY), mSpec.height); }
6. AspectRatioMeasureTest#testExactly()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testExactly() { // width mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); }
7. AspectRatioMeasureTest#testNoAspectRatio()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testNoAspectRatio() { // width mSpec.width = makeMeasureSpec(410, UNSPECIFIED); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 0, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, UNSPECIFIED), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, UNSPECIFIED); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 0, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, UNSPECIFIED), mSpec.height); }
8. AspectRatioMeasureTest#testAspectRatio()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testAspectRatio() { // width mSpec.width = makeMeasureSpec(410, UNSPECIFIED); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(460, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, UNSPECIFIED); LayoutParams layoutParams2 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(210, EXACTLY), mSpec.height); }
9. WXViewUtils#onScreenArea()
Project: weex
File: WXViewUtils.java
File: WXViewUtils.java
public static boolean onScreenArea(View view) { if (view == null || view.getVisibility() != View.VISIBLE) { return false; } int[] p = new int[2]; view.getLocationOnScreen(p); LayoutParams lp = view.getLayoutParams(); int viewH = 0; if (lp != null) { viewH = lp.height; } else { viewH = view.getHeight(); } return (p[1] > 0 && (p[1] - WXViewUtils.getScreenHeight(WXEnvironment.sApplication) < 0)) || (viewH + p[1] > 0 && p[1] <= 0); }
10. ThreadClickDialog#onCreate()
Project: reddit-is-fun
File: ThreadClickDialog.java
File: ThreadClickDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.thread_click_dialog); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; if (display.getOrientation() == Configuration.ORIENTATION_LANDSCAPE) params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); setCanceledOnTouchOutside(true); }
11. CommentClickDialog#onCreate()
Project: reddit-is-fun
File: CommentClickDialog.java
File: CommentClickDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.comment_click_dialog); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; if (display.getOrientation() == Configuration.ORIENTATION_LANDSCAPE) params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); setCanceledOnTouchOutside(true); }
12. QuickReturnHeaderHelper#createView()
Project: QuickReturnHeader
File: QuickReturnHeaderHelper.java
File: QuickReturnHeaderHelper.java
public View createView() { inflater = LayoutInflater.from(context); content = inflater.inflate(contentResId, null); realHeader = inflater.inflate(headerResId, null); realHeaderLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); realHeaderLayoutParams.gravity = Gravity.TOP; // Use measured height here as an estimate of the header height, later on after the layout is complete // we'll use the actual height int widthMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT, MeasureSpec.EXACTLY); int heightMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY); realHeader.measure(widthMeasureSpec, heightMeasureSpec); headerHeight = realHeader.getMeasuredHeight(); listView = (ListView) content.findViewById(android.R.id.list); if (listView != null) { createListView(); } else { createScrollView(); } return root; }
13. ImageGridFragment#onCreateView()
Project: MutiPhotoChoser
File: ImageGridFragment.java
File: ImageGridFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View contentView = inflater.inflate(R.layout.fragment_image_grid_layout, null); imageGridView = (HeaderGridView) contentView.findViewById(R.id.gridGallery); int numColumns = (getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(6, getActivity())) / DisplayUtils.dip2px(116, getActivity()); imageGridView.setNumColumns(numColumns); imageGridView.setVerticalScrollBarEnabled(false); View footerView = new View(getActivity()); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(82, getActivity())); footerView.setLayoutParams(lp); imageGridView.addFooterView(footerView, null, false); mAdapter = new ImageGridAdapter(getActivity(), options); mAdapter.setChoseImageListener(mViewImageListener); mAdapter.swapDatas(mImages); PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), true, true); imageGridView.setOnScrollListener(listener); imageGridView.setOnItemClickListener(this); imageGridView.setAdapter(mAdapter); return contentView; }
14. PhotoDetailsFragment#initThumbnailsList()
Project: mobile-android
File: PhotoDetailsFragment.java
File: PhotoDetailsFragment.java
public void initThumbnailsList(View v) { thumbnailsList = (HorizontalListView) v.findViewById(R.id.thumbs); LayoutParams params = thumbnailsList.getLayoutParams(); params.height = mImageThumbWithBorderSize; thumbnailsList.setLayoutParams(params); thumbnailsList.setAdapter(thumbnailsAdapter); thumbnailsList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TrackerUtils.trackButtonClickEvent("thumb", PhotoDetailsFragment.this); CommonUtils.debug(TAG, "Thumb clicked."); detailsVisible = true; mViewPager.setCurrentItem(position); } }); thumbnailsList.setOnDownListener(new OnDownListener() { @Override public void onDown(MotionEvent e) { CommonUtils.debug(TAG, "Thumbnails List onDown"); detailsVisible = true; } }); }
15. DemoActivity#onRotate()
Project: Masaccio
File: DemoActivity.java
File: DemoActivity.java
private void onRotate() { final MasaccioImageView masaccioImageView = mMasaccioImageView; final int width = masaccioImageView.getWidth(); final int height = masaccioImageView.getHeight(); // swap width and height final LayoutParams layoutParams = masaccioImageView.getLayoutParams(); layoutParams.width = height; layoutParams.height = width; masaccioImageView.setLayoutParams(layoutParams); }
16. HalfHalfModifier#getView()
Project: droidar
File: HalfHalfModifier.java
File: HalfHalfModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); View left = myLeft.getView(context); View right = myRight.getView(context); LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); left.setLayoutParams(params); right.setLayoutParams(params); l.addView(left); l.addView(right); return l; }
17. PlayVideoActivity#fillScreen()
Project: CtsVerifier
File: PlayVideoActivity.java
File: PlayVideoActivity.java
private void fillScreen() { mHolder.setFixedSize(mVideoWidth, mVideoHeight); Rect rect = new Rect(); mVideoFrame.getDrawingRect(rect); LayoutParams lp = mSurfaceView.getLayoutParams(); float aspectRatio = ((float) mVideoWidth) / mVideoHeight; if (rect.width() / aspectRatio <= rect.height()) { lp.width = rect.width(); lp.height = (int) (rect.width() / aspectRatio); } else { lp.width = (int) (rect.height() * aspectRatio); lp.height = rect.height(); } mSurfaceView.setLayoutParams(lp); }
18. Theme#applyLayoutSize()
Project: CSipSimple
File: Theme.java
File: Theme.java
public void applyLayoutSize(View v, String prefix) { LayoutParams lp = v.getLayoutParams(); Integer width = getDimension(prefix + "_width"); Integer height = getDimension(prefix + "_height"); if (width != null) { lp.width = width; } if (height != null) { lp.height = height; } v.setLayoutParams(lp); }
19. RatioDrawable#getWidth()
Project: BeeFramework_Android
File: RatioDrawable.java
File: RatioDrawable.java
private int getWidth(ImageView iv) { int width = 0; LayoutParams lp = iv.getLayoutParams(); if (lp != null) width = lp.width; if (width <= 0) { width = iv.getWidth(); } if (width > 0) { width = width - iv.getPaddingLeft() - iv.getPaddingRight(); } return width; }
20. VideoView#setVideoLayout()
Project: BambooPlayer
File: VideoView.java
File: VideoView.java
/** * Set the display options * * @param layout <ul> * <li>{@link #VIDEO_LAYOUT_ORIGIN} * <li>{@link #VIDEO_LAYOUT_SCALE} * <li>{@link #VIDEO_LAYOUT_STRETCH} * <li>{@link #VIDEO_LAYOUT_ZOOM} * </ul> * @param aspectRatio video aspect ratio, will audo detect if 0. */ public void setVideoLayout(int layout, float aspectRatio) { LayoutParams lp = getLayoutParams(); Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext); int windowWidth = res.first.intValue(), windowHeight = res.second.intValue(); float windowRatio = windowWidth / (float) windowHeight; float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio; mSurfaceHeight = mVideoHeight; mSurfaceWidth = mVideoWidth; if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) { lp.width = (int) (mSurfaceHeight * videoRatio); lp.height = mSurfaceHeight; } else if (layout == VIDEO_LAYOUT_ZOOM) { lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight); lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio); } else { boolean full = layout == VIDEO_LAYOUT_STRETCH; lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight); lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio); } setLayoutParams(lp); getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio); mVideoLayout = layout; mAspectRatio = aspectRatio; }
21. DeadlineControlSet#afterInflate()
Project: astrid
File: DeadlineControlSet.java
File: DeadlineControlSet.java
@Override protected void afterInflate() { dateAndTimePicker = (DateAndTimePicker) getView().findViewById(R.id.date_and_time); LinearLayout extras = (LinearLayout) getView().findViewById(R.id.datetime_extras); for (View v : extraViews) { LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); extras.addView(v, lp); } LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body); body.setGravity(Gravity.CENTER_HORIZONTAL); Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null); DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, (int) (45 * metrics.density)); body.addView(okButton, params); }
22. DateChangedAlerts#setupDialogLayoutParams()
Project: astrid
File: DateChangedAlerts.java
File: DateChangedAlerts.java
private static void setupDialogLayoutParams(Context context, Dialog d) { LayoutParams params = d.getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.WRAP_CONTENT; Configuration config = context.getResources().getConfiguration(); int size = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (AndroidUtilities.getSdkVersion() >= 9 && size == Configuration.SCREENLAYOUT_SIZE_XLARGE || size == Configuration.SCREENLAYOUT_SIZE_LARGE) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); params.width = metrics.widthPixels / 2; } d.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); }
23. TaskEditFragment#setPagerHeightForPosition()
Project: astrid
File: TaskEditFragment.java
File: TaskEditFragment.java
private void setPagerHeightForPosition(int position) { int height = 0; View view = null; switch(getTabForPosition(position)) { case TAB_VIEW_MORE: view = moreControls; break; case TAB_VIEW_UPDATES: view = editNotes; break; } if (view == null || mPager == null) return; int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(), MeasureSpec.AT_MOST); view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); height = Math.max(view.getMeasuredHeight(), height); ; LayoutParams pagerParams = mPager.getLayoutParams(); if (height > 0 && height != pagerParams.height) { pagerParams.height = height; mPager.setLayoutParams(pagerParams); } }
24. Layout_WidthViewAttribute#doSetAttributeValue()
Project: AndroidBinding
File: Layout_WidthViewAttribute.java
File: Layout_WidthViewAttribute.java
@Override protected void doSetAttributeValue(Object newValue) { if (getView() == null) return; LayoutParams param = getView().getLayoutParams(); if (param == null) return; if (newValue == null) { return; } int newWidth = 0; if (newValue instanceof Integer) { newWidth = (Integer) newValue; } else if ("wrap_content".equals(newValue)) { newWidth = LayoutParams.WRAP_CONTENT; } else if ("fill_parent".equals(newValue)) { newWidth = LayoutParams.FILL_PARENT; } param.width = newWidth; getView().setLayoutParams(param); }
25. Layout_HeightViewAttribute#doSetAttributeValue()
Project: AndroidBinding
File: Layout_HeightViewAttribute.java
File: Layout_HeightViewAttribute.java
@Override protected void doSetAttributeValue(Object newValue) { if (getView() == null) return; LayoutParams param = getView().getLayoutParams(); if (param == null) return; if (newValue == null) { return; } int newHeight = 0; if (newValue instanceof Integer) { newHeight = (Integer) newValue; } else if ("wrap_content".equals(newValue)) { newHeight = LayoutParams.WRAP_CONTENT; } else if ("fill_parent".equals(newValue)) { newHeight = LayoutParams.FILL_PARENT; } param.height = newHeight; getView().setLayoutParams(param); }
26. AspectRatioMeasureTest#testAtMost()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testAtMost() { // width exceeded mSpec.width = makeMeasureSpec(410, AT_MOST); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // width within limits mSpec.width = makeMeasureSpec(510, AT_MOST); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams2 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(460, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height exceeded mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(110, AT_MOST); LayoutParams layoutParams3 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams3, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(110, EXACTLY), mSpec.height); // height within limits mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, AT_MOST); LayoutParams layoutParams4 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams4, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(210, EXACTLY), mSpec.height); }
27. AspectRatioMeasureTest#testAtMost()
Project: fresco
File: AspectRatioMeasureTest.java
File: AspectRatioMeasureTest.java
@Test public void testAtMost() { // width exceeded mSpec.width = makeMeasureSpec(410, AT_MOST); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams1 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams1, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // width within limits mSpec.width = makeMeasureSpec(510, AT_MOST); mSpec.height = makeMeasureSpec(310, EXACTLY); LayoutParams layoutParams2 = new LayoutParams(WRAP_CONTENT, MATCH_PARENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 1.5f, layoutParams2, 10, 10); assertEquals(makeMeasureSpec(460, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(310, EXACTLY), mSpec.height); // height exceeded mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(110, AT_MOST); LayoutParams layoutParams3 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams3, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(110, EXACTLY), mSpec.height); // height within limits mSpec.width = makeMeasureSpec(410, EXACTLY); mSpec.height = makeMeasureSpec(310, AT_MOST); LayoutParams layoutParams4 = new LayoutParams(MATCH_PARENT, WRAP_CONTENT); AspectRatioMeasure.updateMeasureSpec(mSpec, 2f, layoutParams4, 10, 10); assertEquals(makeMeasureSpec(410, EXACTLY), mSpec.width); assertEquals(makeMeasureSpec(210, EXACTLY), mSpec.height); }
28. EditPagePort#initBottom()
Project: zhsz
File: EditPagePort.java
File: EditPagePort.java
private void initBottom(LinearLayout llBottom, float ratio) { LinearLayout llAt = new LinearLayout(activity); llAt.setPadding(0, 0, 0, 5); llAt.setBackgroundColor(0xffffffff); int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight); llBottom.addView(llAt, lp); tvAt = new TextView(activity); tvAt.setTextColor(0xff3b3b3b); tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tvAt.setGravity(Gravity.BOTTOM); tvAt.setText("@"); int padding = (int) (DESIGN_LEFT_PADDING * ratio); tvAt.setPadding(padding, 0, padding, 0); lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); llAt.addView(tvAt, lp); tvAt.setOnClickListener(this); if (isShowAtUserLayout(platform.getName())) { tvAt.setVisibility(View.VISIBLE); } else { tvAt.setVisibility(View.INVISIBLE); } tvTextCouter = new TextView(activity); tvTextCouter.setTextColor(0xff3b3b3b); tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT); onTextChanged(etContent.getText(), 0, 0, 0); tvTextCouter.setPadding(padding, 0, padding, 0); lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.weight = 1; llAt.addView(tvTextCouter, lp); View v = new View(activity); v.setBackgroundColor(0xffcccccc); int px_1 = ratio > 1 ? ((int) ratio) : 1; lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1); llBottom.addView(v, lp); }
29. PlatformPage#onCreate()
Project: zhsz
File: PlatformPage.java
File: PlatformPage.java
public void onCreate() { activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000)); initAnims(); LinearLayout llPage = new LinearLayout(activity); llPage.setOrientation(LinearLayout.VERTICAL); activity.setContentView(llPage); TextView vTop = new TextView(activity); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.weight = 1; vTop.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); llPage.addView(vTop, lp); llPanel = new LinearLayout(activity); llPanel.setOrientation(LinearLayout.VERTICAL); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llPanel.setAnimation(animShow); llPage.addView(llPanel, lp); MobViewPager mvp = new MobViewPager(activity); ArrayList<Object> cells = collectCells(); PlatformPageAdapter adapter = newAdapter(cells); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getPanelHeight()); llPanel.addView(mvp, lp); IndicatorView vInd = new IndicatorView(activity); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getBottomHeight()); llPanel.addView(vInd, lp); vInd.setScreenCount(adapter.getCount()); vInd.onScreenChange(0, 0); adapter.setIndicator(vInd); mvp.setAdapter(adapter); }
30. EditPageLand#initBottom()
Project: zhsz
File: EditPageLand.java
File: EditPageLand.java
private void initBottom(LinearLayout llBottom, float ratio) { LinearLayout llAt = new LinearLayout(activity); llAt.setPadding(0, 0, 0, 5); llAt.setBackgroundColor(0xffffffff); int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight); llBottom.addView(llAt, lp); tvAt = new TextView(activity); tvAt.setTextColor(0xff3b3b3b); tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); tvAt.setGravity(Gravity.BOTTOM); tvAt.setText("@"); int padding = (int) (DESIGN_LEFT_PADDING * ratio); tvAt.setPadding(padding, 0, padding, 0); lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); llAt.addView(tvAt, lp); tvAt.setOnClickListener(this); if (isShowAtUserLayout(platform.getName())) { tvAt.setVisibility(View.VISIBLE); } else { tvAt.setVisibility(View.INVISIBLE); } tvTextCouter = new TextView(activity); tvTextCouter.setTextColor(0xff3b3b3b); tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT); onTextChanged(etContent.getText(), 0, 0, 0); tvTextCouter.setPadding(padding, 0, padding, 0); lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.weight = 1; llAt.addView(tvTextCouter, lp); View v = new View(activity); v.setBackgroundColor(0xffcccccc); int px_1 = ratio > 1 ? ((int) ratio) : 1; lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1); llBottom.addView(v, lp); }
31. ListModifier#addListItemView()
Project: droidar
File: ListModifier.java
File: ListModifier.java
private void addListItemView(final LinearLayout targetView, final ModifierInterface modifierInterface, final int posInList, Context context) { /* * Set the weights of the elements 9 to 1 to not waste space with the * delete button */ LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LayoutParams p1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 9); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); final LinearLayout l = new LinearLayout(context); l.setLayoutParams(p); l.setGravity(Gravity.CENTER_VERTICAL); View v = modifierInterface.getView(context); v.setLayoutParams(p1); l.addView(v); if (myItemsDeletable) { Button deleteButton = new Button(context); deleteButton.setText("-"); v.setLayoutParams(p2); deleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { if (deleteItem(posInList, modifierInterface)) { if (!myList.remove(modifierInterface)) { Log.e("SmartUI", "There was some " + "inconsisancy in the SartUI " + "Code (method addListItemView" + "(..)! Check the code, find " + "the error, get famous"); } targetView.removeView(l); } } catch (Exception e) { Log.e("SmartUI", "Item could not be removed correctly. " + "Check SmartUI code!"); e.printStackTrace(); } } }); l.addView(deleteButton); } targetView.addView(l); }
32. EditPagePort#initBody()
Project: zhsz
File: EditPagePort.java
File: EditPagePort.java
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.VERTICAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
33. EditPagePort#initTitle()
Project: zhsz
File: EditPagePort.java
File: EditPagePort.java
private void initTitle(RelativeLayout rlTitle, float ratio) { tvCancel = new TextView(activity); tvCancel.setTextColor(0xff3b3b3b); tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvCancel.setGravity(Gravity.CENTER); int resId = R.getStringRes(activity, "ssdk_oks_cancel"); if (resId > 0) { tvCancel.setText(resId); } int padding = (int) (DESIGN_LEFT_PADDING * ratio); tvCancel.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); rlTitle.addView(tvCancel, lp); tvCancel.setOnClickListener(this); TextView tvTitle = new TextView(activity); tvTitle.setTextColor(0xff3b3b3b); tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tvTitle.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_multi_share"); if (resId > 0) { tvTitle.setText(resId); } lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); rlTitle.addView(tvTitle, lp); tvShare = new TextView(activity); tvShare.setTextColor(0xffff6d11); tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvShare.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_share"); if (resId > 0) { tvShare.setText(resId); } tvShare.setPadding(padding, 0, padding, 0); lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlTitle.addView(tvShare, lp); tvShare.setOnClickListener(this); }
34. EditPagePort#onCreate()
Project: zhsz
File: EditPagePort.java
File: EditPagePort.java
public void onCreate() { super.onCreate(); int screenHeight = R.getScreenHeight(activity); float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT; maxBodyHeight = 0; llPage = new LinearLayout(activity); llPage.setOrientation(LinearLayout.VERTICAL); activity.setContentView(llPage); rlTitle = new RelativeLayout(activity); rlTitle.setBackgroundColor(0xffe6e9ec); int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight); llPage.addView(rlTitle, lp); initTitle(rlTitle, ratio); RelativeLayout rlBody = new RelativeLayout(activity); rlBody.setBackgroundColor(0xffffffff); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llPage.addView(rlBody, lp); initBody(rlBody, ratio); LinearLayout llShadow = new LinearLayout(activity); llShadow.setOrientation(LinearLayout.VERTICAL); rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); initShadow(llShadow, ratio); llBottom = new LinearLayout(activity); llBottom.setOrientation(LinearLayout.VERTICAL); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llPage.addView(llBottom, lp); initBottom(llBottom, ratio); }
35. EditPageLand#initBody()
Project: zhsz
File: EditPageLand.java
File: EditPageLand.java
private void initBody(RelativeLayout rlBody, float ratio) { svContent = new ScrollView(activity); rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); LinearLayout llContent = new LinearLayout(activity); llContent.setOrientation(LinearLayout.HORIZONTAL); svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setBackgroundDrawable(null); etContent.setTextColor(0xff3b3b3b); etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); rlThumb = new RelativeLayout(activity); rlThumb.setBackgroundColor(0xff313131); int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio); int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp); aivThumb = new AsyncImageView(activity) { public void onImageGot(String url, Bitmap bm) { thumb = bm; super.onImageGot(url, bm); } }; aivThumb.setScaleToCropCenter(true); RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth); rlThumb.addView(aivThumb, rllp); aivThumb.setOnClickListener(this); initThumb(aivThumb); xvRemove = new XView(activity); xvRemove.setRatio(ratio); rllp = new RelativeLayout.LayoutParams(xWidth, xWidth); rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlThumb.addView(xvRemove, rllp); xvRemove.setOnClickListener(this); }
36. EditPageLand#initTitle()
Project: zhsz
File: EditPageLand.java
File: EditPageLand.java
private void initTitle(RelativeLayout rlTitle, float ratio) { tvCancel = new TextView(activity); tvCancel.setTextColor(0xff3b3b3b); tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvCancel.setGravity(Gravity.CENTER); int resId = R.getStringRes(activity, "ssdk_oks_cancel"); if (resId > 0) { tvCancel.setText(resId); } int padding = (int) (DESIGN_LEFT_PADDING * ratio); tvCancel.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); rlTitle.addView(tvCancel, lp); tvCancel.setOnClickListener(this); TextView tvTitle = new TextView(activity); tvTitle.setTextColor(0xff3b3b3b); tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tvTitle.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_multi_share"); if (resId > 0) { tvTitle.setText(resId); } lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); rlTitle.addView(tvTitle, lp); tvShare = new TextView(activity); tvShare.setTextColor(0xffff6d11); tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvShare.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_share"); if (resId > 0) { tvShare.setText(resId); } tvShare.setPadding(padding, 0, padding, 0); lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlTitle.addView(tvShare, lp); tvShare.setOnClickListener(this); }
37. EditPageLand#onCreate()
Project: zhsz
File: EditPageLand.java
File: EditPageLand.java
public void onCreate() { super.onCreate(); int screenHeight = R.getScreenHeight(activity); float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH; maxBodyHeight = 0; llPage = new LinearLayout(activity); llPage.setOrientation(LinearLayout.VERTICAL); activity.setContentView(llPage); rlTitle = new RelativeLayout(activity); rlTitle.setBackgroundColor(0xffe6e9ec); int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight); llPage.addView(rlTitle, lp); initTitle(rlTitle, ratio); RelativeLayout rlBody = new RelativeLayout(activity); rlBody.setBackgroundColor(0xffffffff); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llPage.addView(rlBody, lp); initBody(rlBody, ratio); LinearLayout llShadow = new LinearLayout(activity); llShadow.setOrientation(LinearLayout.VERTICAL); rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); initShadow(llShadow, ratio); llBottom = new LinearLayout(activity); llBottom.setOrientation(LinearLayout.VERTICAL); lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llPage.addView(llBottom, lp); initBottom(llBottom, ratio); }
38. FriendListPage#initTitle()
Project: zhsz
File: FriendListPage.java
File: FriendListPage.java
private void initTitle(RelativeLayout rlTitle, float ratio) { tvCancel = new TextView(activity); tvCancel.setTextColor(0xff3b3b3b); tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvCancel.setGravity(Gravity.CENTER); int resId = R.getStringRes(activity, "ssdk_oks_cancel"); if (resId > 0) { tvCancel.setText(resId); } int padding = (int) (DESIGN_LEFT_PADDING * ratio); tvCancel.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); rlTitle.addView(tvCancel, lp); tvCancel.setOnClickListener(this); TextView tvTitle = new TextView(activity); tvTitle.setTextColor(0xff3b3b3b); tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tvTitle.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_contacts"); if (resId > 0) { tvTitle.setText(resId); } lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); rlTitle.addView(tvTitle, lp); tvConfirm = new TextView(activity); tvConfirm.setTextColor(0xffff6d11); tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvConfirm.setGravity(Gravity.CENTER); resId = R.getStringRes(activity, "ssdk_oks_confirm"); if (resId > 0) { tvConfirm.setText(resId); } tvConfirm.setPadding(padding, 0, padding, 0); lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); rlTitle.addView(tvConfirm, lp); tvConfirm.setOnClickListener(this); }
39. AppRunnerFragment#initLayout()
Project: Protocoder
File: AppRunnerFragment.java
File: AppRunnerFragment.java
public RelativeLayout initLayout() { LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // add main layout mainLayout = new RelativeLayout(mActivity); mainLayout.setLayoutParams(layoutParams); mainLayout.setGravity(Gravity.BOTTOM); // mainLayout.setBackgroundColor(getResources().getColor(R.color.transparent)); mainLayout.setBackgroundColor(getResources().getColor(R.color.white)); // set the parent parentScriptedLayout = new RelativeLayout(mActivity); parentScriptedLayout.setLayoutParams(layoutParams); parentScriptedLayout.setGravity(Gravity.BOTTOM); parentScriptedLayout.setBackgroundColor(getResources().getColor(R.color.transparent)); mainLayout.addView(parentScriptedLayout); // editor layout editorLayout = new FrameLayout(mActivity); FrameLayout.LayoutParams editorParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); editorLayout.setLayoutParams(editorParams); editorLayout.setId(EDITOR_ID); mainLayout.addView(editorLayout); // console layout consoleRLayout = new RelativeLayout(mActivity); RelativeLayout.LayoutParams consoleLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.apprunner_console)); consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); consoleRLayout.setLayoutParams(consoleLayoutParams); consoleRLayout.setGravity(Gravity.BOTTOM); consoleRLayout.setBackgroundColor(getResources().getColor(R.color.blacktransparent)); consoleRLayout.setVisibility(View.GONE); mainLayout.addView(consoleRLayout); // Create the text view to add to the console layout consoleText = new TextView(mActivity); LayoutParams consoleTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); consoleText.setBackgroundColor(getResources().getColor(R.color.transparent)); consoleText.setTextColor(getResources().getColor(R.color.white)); consoleText.setLayoutParams(consoleTextParams); int textPadding = getResources().getDimensionPixelSize(R.dimen.apprunner_console_text_padding); consoleText.setPadding(textPadding, textPadding, textPadding, textPadding); consoleRLayout.addView(consoleText); //add a close button Button closeBtn = new Button(mActivity); closeBtn.setText("x"); closeBtn.setPadding(5, 5, 5, 5); closeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showConsole(false); } }); RelativeLayout.LayoutParams closeBtnLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); closeBtn.setLayoutParams(closeBtnLayoutParams); consoleRLayout.addView(closeBtn); liveCoding = new PLiveCodingFeedback(mActivity); mainLayout.addView(liveCoding.add()); return mainLayout; }
40. VideoViewHard#setVideoLayout()
Project: NewsMe
File: VideoViewHard.java
File: VideoViewHard.java
public void setVideoLayout(int layout, float aspectRatio) { log("setVideoLayout() into"); LayoutParams lp = getLayoutParams(); DisplayMetrics disp = mContext.getResources().getDisplayMetrics(); int windowWidth = disp.widthPixels, windowHeight = disp.heightPixels; View p = (View) getParent(); if (p == null) { return; } // LogS.d(TAG, // "disp.widthPixels="+disp.widthPixels+",disp.heightPixels="+disp.heightPixels+ // ",p.getWidth()="+ p.getWidth() + "p.getHeight()="+ p.getHeight()); LayoutParams p_lp = p.getLayoutParams(); if (p_lp != null) { if (p_lp.width == -1) { // /windowWidth = windowWidth = disp.widthPixels; // p.getMeasuredWidth(); // LogS.d(TAG, // "p_lp.width==-1,p.getMeasuredWidth()=" // + windowWidth); } else { windowWidth = p_lp.width; } if (p_lp.height == -1) { // /windowHeight = windowHeight = disp.heightPixels; // p.getMeasuredHeight(); // LogS.d(TAG, // "p_lp.height==-1,p.getMeasuredHeight()=" // + windowHeight); } else { windowHeight = p_lp.height; } } else { // LogS.d(TAG, "p_lp NULL,windowWidth=" + disp.widthPixels + // ",windowHeight=" + disp.heightPixels); } // LogS.d(TAG, "setVideoLayout mSurfaceView : width = " + lp.width + // " , height = " + lp.height); // LogS.d(TAG, "setVideoLayout parent width = " + windowWidth + // " , height = " + windowHeight); float windowRatio = windowWidth / (float) windowHeight; float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio; if (videoRatio < 0.01f) { LogS.d(TAG, "video Ratio error " + videoRatio); return; } mSurfaceHeight = mVideoHeight; mSurfaceWidth = mVideoWidth; if (VIDEO_SCALE_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) { lp.width = (int) (mSurfaceHeight * videoRatio); lp.height = mSurfaceHeight; setLayoutParams(lp); // /getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); } else if (layout == VIDEO_SCALE_CENTER_CROP) { lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight); lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio); setLayoutParams(lp); // /getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); } else { boolean full = layout == VIDEO_SCALE_FIT_STRENTH; lp.width = (full || windowRatio < videoRatio) ? windowWidth : videoRatio == 0 ? windowWidth : (int) (videoRatio * windowHeight); lp.height = (full || windowRatio > videoRatio) ? windowHeight : videoRatio == 0 ? windowHeight : (int) (windowWidth / videoRatio); setLayoutParams(lp); // /getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); } // LogS.d(TAG, "setVideoLayout : windowRatio = " + windowRatio + // " , videoRatio = " + videoRatio + " , aspectRatio = " + aspectRatio); // LogS.d(TAG, "setVideoLayout : lp.width = " + lp.width + // " , lp.height = " + lp.height + " , mSurfaceWidth = " + mSurfaceWidth // + " , mSurfaceHeight = " + mSurfaceHeight); // getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); // LogS.d(TAG, // "VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", // mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, // mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, // windowRatio); mVideoLayout = layout; mAspectRatio = aspectRatio; log("setVideoLayout() out"); }
41. M_ProgressBar#getView()
Project: droidar
File: M_ProgressBar.java
File: M_ProgressBar.java
@Override public View getView(Context context) { container = new LinearLayout(context); container.setOrientation(LinearLayout.VERTICAL); container.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); nameText = new TextView(context); nameText.setText(getVarName()); nameText.setLayoutParams(p); container.addView(nameText); progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal); progressBar.setLayoutParams(p2); progressBar.setProgress(loadInitValue()); progressBar.setMax(loadMaxValue()); container.addView(progressBar); container.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); if (myDecorator != null) { int currentLevel = myDecorator.getCurrentLevel(); myDecorator.decorate(context, nameText, currentLevel + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, progressBar, currentLevel + 1, UiDecorator.TYPE_EDIT_TEXT); } return container; }
42. M_PlusMinus#getView()
Project: droidar
File: M_PlusMinus.java
File: M_PlusMinus.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setText(getVarName()); t.setLayoutParams(p); l.addView(t); LinearLayout l2 = new LinearLayout(context); l2.setLayoutParams(p2); l2.setGravity(Gravity.CENTER); final ImageButton minusBtn = new ImageButton(context); if (myMinusImageId != -1) { minusBtn.setImageResource(myMinusImageId); minusBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { valueText.setText(minusEvent(minusBtn, getCurrentValue())); } }); LinearLayout l3 = new LinearLayout(context); l3.setLayoutParams(p2); l3.setGravity(Gravity.CENTER_HORIZONTAL); l3.addView(minusBtn); l2.addView(l3); } valueText = new TextView(context); valueText.setText("" + load()); LinearLayout l4 = new LinearLayout(context); l4.setLayoutParams(p2); l4.setGravity(Gravity.CENTER_HORIZONTAL); l4.addView(valueText); l2.addView(l4); final ImageButton plusBtn = new ImageButton(context); if (myPlusImageId != -1) { plusBtn.setImageResource(myPlusImageId); plusBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { valueText.setText(plusEvent(plusBtn, getCurrentValue())); } }); LinearLayout l5 = new LinearLayout(context); l5.setLayoutParams(p2); l5.setGravity(Gravity.CENTER_HORIZONTAL); l5.addView(plusBtn); l2.addView(l5); } l.addView(l2); l.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); if (plusBtn != null) myDecorator.decorate(context, plusBtn, level + 1, UiDecorator.TYPE_BUTTON); if (minusBtn != null) myDecorator.decorate(context, minusBtn, level + 1, UiDecorator.TYPE_BUTTON); myDecorator.decorate(context, t, level + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, valueText, level + 1, UiDecorator.TYPE_INFO_TEXT); } return l; }
43. M_Integer#getView()
Project: droidar
File: M_Integer.java
File: M_Integer.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfDescription); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfInputText); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); // TODO replace by better view representative: e = new EditText(context); e.setLayoutParams(p2); e.setText("" + load()); e.setInputType(InputType.TYPE_CLASS_NUMBER); e.setKeyListener(new DigitsKeyListener(true, false)); setEditable(isEditable()); if (minimumValue != null && maximumValue != null) setMinMaxFilterFor(e, minimumValue, maximumValue); l.addView(e); l.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); myDecorator.decorate(context, t, level + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, e, level + 1, UiDecorator.TYPE_EDIT_TEXT); } return l; }
44. M_EmailInput#getView()
Project: droidar
File: M_EmailInput.java
File: M_EmailInput.java
@Override public View getView(Context context) { LinearLayout container = new LinearLayout(context); container.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView nameText = new TextView(context); nameText.setText(getVarName()); nameText.setLayoutParams(p); container.addView(nameText); editText = new EditText(context); editText.setLayoutParams(p2); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); if (myDecorator != null) { int currentLevel = myDecorator.getCurrentLevel(); myDecorator.decorate(context, nameText, currentLevel + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, editText, currentLevel + 1, UiDecorator.TYPE_EDIT_TEXT); } originalEditTextColor = editText.getCurrentTextColor(); editText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (emailIsOk(editText.getText().toString())) { setEditTextToNormal(editText); } else { setEditTextToError(editText); } return false; } }); editText.setText(load()); container.addView(editText); container.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); return container; }
45. M_Double#getView()
Project: droidar
File: M_Double.java
File: M_Double.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfDescription); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfInputText); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); // TODO replace by better view representative: e = new EditText(context); e.setLayoutParams(p2); e.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); e.setText("" + load()); e.setEnabled(editable); e.setFocusable(editable); e.setFocusableInTouchMode(editable); l.addView(e); l.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); myDecorator.decorate(context, t, level + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, e, level + 1, UiDecorator.TYPE_EDIT_TEXT); } return l; }
46. M_Checkbox#getView()
Project: droidar
File: M_Checkbox.java
File: M_Checkbox.java
@Override public View getView(final Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); l.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfDescription); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfInputText); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); t.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (e != null && e.isEnabled()) { e.setChecked(!e.isChecked()); } } }); // TODO replace by better view representative: e = new CheckBox(context); e.setChecked(loadVar()); e.setEnabled(editable); e.setFocusable(editable); e.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { M_Checkbox.this.onCheckedChanged(context, e, isChecked); } }); LinearLayout l2 = new LinearLayout(context); l2.setLayoutParams(p2); l2.setGravity(Gravity.RIGHT); l2.addView(e); l.addView(l2); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); myDecorator.decorate(context, t, level, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, e, level, UiDecorator.TYPE_EDIT_TEXT); } return l; }
47. TextModifier#getView()
Project: droidar
File: TextModifier.java
File: TextModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setText(getVarName()); t.setLayoutParams(p); l.addView(t); e = new EditText(context); e.setLayoutParams(p2); e.setText(load()); l.addView(e); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal1(e); } return l; }
48. PlusMinusModifier#getView()
Project: droidar
File: PlusMinusModifier.java
File: PlusMinusModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setText(getVarName()); t.setLayoutParams(p); l.addView(t); LinearLayout l2 = new LinearLayout(context); l2.setLayoutParams(p2); if (myMinusImage != -1) { Button minus = new Button(context); minus.setBackgroundResource(myMinusImage); minus.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { valueText.setText("" + minusEvent(getCurrentValue())); } }); LinearLayout l3 = new LinearLayout(context); l3.setLayoutParams(p2); l3.setGravity(Gravity.CENTER_HORIZONTAL); l3.addView(minus); l2.addView(l3); } valueText = new TextView(context); valueText.setText("" + load()); LinearLayout l4 = new LinearLayout(context); l4.setLayoutParams(p2); l4.setGravity(Gravity.CENTER_HORIZONTAL); l4.addView(valueText); l2.addView(l4); if (myPlusImage != -1) { Button plus = new Button(context); // plus.setLayoutParams(p2); plus.setBackgroundResource(myPlusImage); plus.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { valueText.setText("" + plusEvent(getCurrentValue())); } }); LinearLayout l5 = new LinearLayout(context); l5.setLayoutParams(p2); l5.setGravity(Gravity.CENTER_HORIZONTAL); l5.addView(plus); l2.addView(l5); } l.addView(l2); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal1(valueText); } return l; }
49. IntModifier#getView()
Project: droidar
File: IntModifier.java
File: IntModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); // TODO replace by better view representative: e = new EditText(context); e.setLayoutParams(p2); e.setText("" + load()); l.addView(e); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal1(e); } return l; }
50. DoubleModifier#getView()
Project: droidar
File: DoubleModifier.java
File: DoubleModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); // TODO replace by better view representative: e = new EditText(context); e.setLayoutParams(p2); e.setText("" + load()); l.addView(e); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal1(e); } return l; }
51. ColorModifier#getView()
Project: droidar
File: ColorModifier.java
File: ColorModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setText(getVarName()); t.setLayoutParams(p); l.addView(t); LinearLayout l2 = new LinearLayout(context); l2.setLayoutParams(p2); OnKeyListener k = new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { updateColor(); return false; } }; eAlpha = new EditText(context); eAlpha.setLayoutParams(p2); eAlpha.setOnKeyListener(k); l2.addView(eAlpha); eRed = new EditText(context); eRed.setLayoutParams(p2); eRed.setOnKeyListener(k); l2.addView(eRed); eGreen = new EditText(context); eGreen.setLayoutParams(p2); eGreen.setOnKeyListener(k); l2.addView(eGreen); eBlue = new EditText(context); eBlue.setLayoutParams(p2); eBlue.setOnKeyListener(k); l2.addView(eBlue); eAlpha.setText(getAlpha()); eRed.setText(getRed()); eGreen.setText(getGreen()); eBlue.setText(getBlue()); updateColor(); l.addView(l2); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal2(eAlpha); getTheme().applyNormal2(eBlue); getTheme().applyNormal2(eGreen); getTheme().applyNormal2(eRed); } return l; }
52. BoolModifier#getView()
Project: droidar
File: BoolModifier.java
File: BoolModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); l.setGravity(Gravity.CENTER_VERTICAL); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 2); LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); TextView t = new TextView(context); t.setLayoutParams(p); t.setText(this.getVarName()); l.addView(t); // TODO replace by better view representative: e = new CheckBox(context); e.setLayoutParams(p2); e.setChecked(loadVar()); l.addView(e); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(t); getTheme().applyNormal1(e); } return l; }
53. VimTouch#showCmdHistory()
Project: vimtouch
File: VimTouch.java
File: VimTouch.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void showCmdHistory() { final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim); // Setting dialogview Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM); window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); dialog.setTitle(null); dialog.setContentView(R.layout.hist_list); dialog.setCancelable(true); LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout); if (AndroidCompat.SDK >= 11) { layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE | LinearLayout.SHOW_DIVIDER_END); } LayoutParams params = layout.getLayoutParams(); params.width = mScreenWidth; layout.setLayoutParams(params); LayoutInflater inflater = LayoutInflater.from(this); boolean exists = false; for (int i = 0; i < 10; i++) { TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false); //String cmd = Exec.getCmdHistory(i); //if(cmd.length() == 0) break; //exists = true; //button.setText(":"+cmd); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView text = (TextView) v; CharSequence cmd = text.getText(); if (cmd.length() > 1) { ; } Exec.doCommand(cmd.subSequence(1, cmd.length()).toString()); dialog.dismiss(); } }); layout.addView((View) button); button.setVisibility(View.GONE); mHistoryButtons[i] = button; } Exec.getHistory(); //if(exists) dialog.show(); }
54. VideoPlayerActivity#changeSurfaceLayout()
Project: VCL-Android
File: VideoPlayerActivity.java
File: VideoPlayerActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void changeSurfaceLayout() { int sw; int sh; // get screen size if (mPresentation == null) { sw = getWindow().getDecorView().getWidth(); sh = getWindow().getDecorView().getHeight(); } else { sw = mPresentation.getWindow().getDecorView().getWidth(); sh = mPresentation.getWindow().getDecorView().getHeight(); } if (mService != null) { final IVLCVout vlcVout = mService.getVLCVout(); vlcVout.setWindowSize(sw, sh); } double dw = sw, dh = sh; boolean isPortrait; if (mPresentation == null) { // getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; } else { isPortrait = false; } if (sw > sh && isPortrait || sw < sh && !isPortrait) { dw = sh; dh = sw; } // sanity check if (dw * dh == 0 || mVideoWidth * mVideoHeight == 0) { Log.e(TAG, "Invalid surface size"); return; } // compute the aspect ratio double ar, vw; if (mSarDen == mSarNum) { /* No indication about the density, assuming 1:1 */ vw = mVideoVisibleWidth; ar = (double) mVideoVisibleWidth / (double) mVideoVisibleHeight; } else { /* Use the specified aspect ratio */ vw = mVideoVisibleWidth * (double) mSarNum / mSarDen; ar = vw / mVideoVisibleHeight; } // compute the display aspect ratio double dar = dw / dh; switch(mCurrentSize) { case SURFACE_BEST_FIT: if (dar < ar) dh = dw / ar; else dw = dh * ar; break; case SURFACE_FIT_HORIZONTAL: dh = dw / ar; break; case SURFACE_FIT_VERTICAL: dw = dh * ar; break; case SURFACE_FILL: break; case SURFACE_16_9: ar = 16.0 / 9.0; if (dar < ar) dh = dw / ar; else dw = dh * ar; break; case SURFACE_4_3: ar = 4.0 / 3.0; if (dar < ar) dh = dw / ar; else dw = dh * ar; break; case SURFACE_ORIGINAL: dh = mVideoVisibleHeight; dw = vw; break; } SurfaceView surface; SurfaceView subtitlesSurface; FrameLayout surfaceFrame; if (mPresentation == null) { surface = mSurfaceView; subtitlesSurface = mSubtitlesSurfaceView; surfaceFrame = mSurfaceFrame; } else { surface = mPresentation.mSurfaceView; subtitlesSurface = mPresentation.mSubtitlesSurfaceView; surfaceFrame = mPresentation.mSurfaceFrame; } // set display size LayoutParams lp = surface.getLayoutParams(); lp.width = (int) Math.ceil(dw * mVideoWidth / mVideoVisibleWidth); lp.height = (int) Math.ceil(dh * mVideoHeight / mVideoVisibleHeight); surface.setLayoutParams(lp); if (subtitlesSurface != null) subtitlesSurface.setLayoutParams(lp); // set frame size (crop if necessary) lp = surfaceFrame.getLayoutParams(); lp.width = (int) Math.floor(dw); lp.height = (int) Math.floor(dh); surfaceFrame.setLayoutParams(lp); surface.invalidate(); if (subtitlesSurface != null) subtitlesSurface.invalidate(); }
55. AppMsg#setLayoutGravity()
Project: v2ex-daily-android
File: AppMsg.java
File: AppMsg.java
/** * Constructs and sets the layout parameters to have some gravity. * * @param gravity the gravity of the Crouton * @return <code>this</code>, for chaining. * @see android.view.Gravity */ public AppMsg setLayoutGravity(int gravity) { mLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, gravity); return this; }
56. DimensionCalculator#getMargins()
Project: UltimateRecyclerView
File: DimensionCalculator.java
File: DimensionCalculator.java
/** * Returns {@link Rect} representing margins for any view. * * @param view for which to get margins * @return margins for the given view. All 0 if the view does not support margins */ public Rect getMargins(View view) { LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof MarginLayoutParams) { MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams; return getMarginRect(marginLayoutParams); } else { return new Rect(); } }
57. ExpandableListItemAdapter#getView()
Project: UltimateAndroid
File: ExpandableListItemAdapter.java
File: ExpandableListItemAdapter.java
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (titleView != viewHolder.titleView) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (contentView != viewHolder.contentView) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
58. FadingActionBarHelperBase#updateHeaderHeight()
Project: UltimateAndroid
File: FadingActionBarHelperBase.java
File: FadingActionBarHelperBase.java
private void updateHeaderHeight(int headerHeight) { LayoutParams params = (LayoutParams) mMarginView.getLayoutParams(); params.height = headerHeight; mMarginView.setLayoutParams(params); if (mListViewBackgroundView != null) { FrameLayout.LayoutParams params2 = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams(); params2.topMargin = headerHeight; mListViewBackgroundView.setLayoutParams(params2); } mLastHeaderHeight = headerHeight; }
59. HighlightAnimation#animate()
Project: UltimateAndroid
File: HighlightAnimation.java
File: HighlightAnimation.java
@Override public void animate() { final FrameLayout highlightFrame = new FrameLayout(view.getContext()); LayoutParams layoutParams = new LayoutParams(view.getWidth(), view.getHeight()); ImageView highlightView = new ImageView(view.getContext()); highlightView.setBackgroundColor(color); highlightView.setAlpha(0.5f); highlightView.setVisibility(View.VISIBLE); final ViewGroup parentView = (ViewGroup) view.getParent(); final int positionView = parentView.indexOfChild(view); parentView.addView(highlightFrame, positionView, layoutParams); highlightFrame.setX(view.getLeft()); highlightFrame.setY(view.getTop()); parentView.removeView(view); highlightFrame.addView(view); highlightFrame.addView(highlightView); highlightView.animate().alpha(0).setInterpolator(interpolator).setDuration(duration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { highlightFrame.removeAllViews(); parentView.addView(view, positionView); view.setX(highlightFrame.getLeft()); view.setY(highlightFrame.getTop()); parentView.removeView(highlightFrame); if (getListener() != null) { getListener().onAnimationEnd(HighlightAnimation.this); } } }); }
60. FadingActionBarHelperBase#updateHeaderHeight()
Project: UltimateAndroid
File: FadingActionBarHelperBase.java
File: FadingActionBarHelperBase.java
private void updateHeaderHeight(int headerHeight) { LayoutParams params = (LayoutParams) mMarginView.getLayoutParams(); params.height = headerHeight; mMarginView.setLayoutParams(params); if (mListViewBackgroundView != null) { FrameLayout.LayoutParams params2 = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams(); params2.topMargin = headerHeight; mListViewBackgroundView.setLayoutParams(params2); } mLastHeaderHeight = headerHeight; }
61. ExpandableListItemAdapter#getView()
Project: UltimateAndroid
File: ExpandableListItemAdapter.java
File: ExpandableListItemAdapter.java
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (titleView != viewHolder.titleView) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (contentView != viewHolder.contentView) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
62. HighlightAnimation#animate()
Project: UltimateAndroid
File: HighlightAnimation.java
File: HighlightAnimation.java
@Override public void animate() { final FrameLayout highlightFrame = new FrameLayout(view.getContext()); LayoutParams layoutParams = new LayoutParams(view.getWidth(), view.getHeight()); ImageView highlightView = new ImageView(view.getContext()); highlightView.setBackgroundColor(color); highlightView.setAlpha(0.5f); highlightView.setVisibility(View.VISIBLE); final ViewGroup parentView = (ViewGroup) view.getParent(); final int positionView = parentView.indexOfChild(view); parentView.addView(highlightFrame, positionView, layoutParams); highlightFrame.setX(view.getLeft()); highlightFrame.setY(view.getTop()); parentView.removeView(view); highlightFrame.addView(view); highlightFrame.addView(highlightView); highlightView.animate().alpha(0).setInterpolator(interpolator).setDuration(duration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { highlightFrame.removeAllViews(); parentView.addView(view, positionView); view.setX(highlightFrame.getLeft()); view.setY(highlightFrame.getTop()); parentView.removeView(highlightFrame); if (getListener() != null) { getListener().onAnimationEnd(HighlightAnimation.this); } } }); }
63. DimensionCalculator#initMargins()
Project: sticky-headers-recyclerview
File: DimensionCalculator.java
File: DimensionCalculator.java
/** * Populates {@link Rect} with margins for any view. * * * @param margins rect to populate * @param view for which to get margins */ public void initMargins(Rect margins, View view) { LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof MarginLayoutParams) { MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams; initMarginRect(margins, marginLayoutParams); } else { margins.set(0, 0, 0, 0); } }
64. TwitterAuthUtils#showAuthDialog()
Project: socialize-sdk-android
File: TwitterAuthUtils.java
File: TwitterAuthUtils.java
public Dialog showAuthDialog(final Context context, TwitterAuthProviderInfo info, final TwitterAuthListener listener) { Dialog dialog = newDialog(context); dialog.setTitle("Twitter Authentication"); dialog.setCancelable(true); dialog.setOnCancelListener(newOnCancelListener(listener)); TwitterAuthView view = twitterAuthViewFactory.getBean(info.getConsumerKey(), info.getConsumerSecret()); LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); view.setLayoutParams(params); dialog.setContentView(view); view.setTwitterAuthListener(newTwitterAuthDialogListener(dialog, listener)); view.authenticate(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; DialogRegistration.register(context, dialog); dialog.show(); return dialog; }
65. BadgeView#applyTo()
Project: serenity-android
File: BadgeView.java
File: BadgeView.java
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // TODO verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }
66. BadgeView#applyTo()
Project: RefreshActionItem
File: BadgeView.java
File: BadgeView.java
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // TODO verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }
67. BadgeView#applyTo()
Project: RefreshActionItem
File: BadgeView.java
File: BadgeView.java
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // TODO verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }
68. GameActivity#setContentView()
Project: playn
File: GameActivity.java
File: GameActivity.java
protected void setContentView(GameViewGL view) { LinearLayout layout = new LinearLayout(this); layout.setBackgroundColor(0xFF000000); layout.setGravity(Gravity.CENTER); layout.addView(gameView); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); getWindow().setContentView(layout, params); }
69. CheckBoxViewSample#createViews()
Project: pixate-freestyle-android
File: CheckBoxViewSample.java
File: CheckBoxViewSample.java
@Override public void createViews(Context context, ViewGroup layout) { CheckBox child = new CheckBox(context); PixateFreestyle.setStyleId(child, "myCheckbox"); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layout.addView(child, params); child.setText("Priority shipping"); addView(child); }
70. MultiColumnImageAdapter#createNewSlotView()
Project: picview-for-android
File: MultiColumnImageAdapter.java
File: MultiColumnImageAdapter.java
/** * Creates a new slot view. * * @param parent * the parent of the created view */ private ThumbnailSlotView createNewSlotView(ViewGroup parent) { // Inflate a new slot. ThumbnailSlotView slot = (ThumbnailSlotView) inflater.inflate(R.layout.picture_entry, parent, false); LayoutParams layoutParams = slot.getLayoutParams(); layoutParams.width = slotWidth; slot.setLayoutParams(layoutParams); slot.setGravity(Gravity.CENTER_HORIZONTAL); slot.setId(R.layout.picture_entry); return slot; }
71. ExpandableListItemAdapter#getView()
Project: ListViewAnimations
File: ExpandableListItemAdapter.java
File: ExpandableListItemAdapter.java
@Override @NonNull public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (!titleView.equals(viewHolder.titleView)) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (!contentView.equals(viewHolder.contentView)) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
72. _HoloActivity#requestDecorView()
Project: HoloEverywhere
File: _HoloActivity.java
File: _HoloActivity.java
private boolean requestDecorView(View view, LayoutParams params, int layoutRes) { if (mDecorView != null) { return true; } mDecorView = new ActivityDecorView(); mDecorView.setId(android.R.id.content); mDecorView.setProvider(this); if (view != null) { mDecorView.addView(view, params); } else if (layoutRes > 0) { getThemedLayoutInflater().inflate(layoutRes, mDecorView, true); } final LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); performAddonAction(new AddonCallback<IAddonActivity>() { @Override public boolean action(IAddonActivity addon) { return addon.installDecorView(mDecorView, p); } @Override public void justPost() { _HoloActivity.super.setContentView(mDecorView, p); } }); return false; }
73. SeekBarPreference#onCreateDialogView()
Project: fanfouapp-opensource
File: SeekBarPreference.java
File: SeekBarPreference.java
@Override protected View onCreateDialogView() { LinearLayout.LayoutParams params; final LinearLayout layout = new LinearLayout(this.mContext); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(6, 6, 6, 6); if (this.mDialogMessage != null) { this.mMessageText = new TextView(this.mContext); this.mMessageText.setText(this.mDialogMessage); layout.addView(this.mMessageText); } this.mValueText = new TextView(this.mContext); this.mValueText.setGravity(Gravity.CENTER_HORIZONTAL); this.mValueText.setTextSize(32); params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layout.addView(this.mValueText, params); this.mSeekBar = new SeekBar(this.mContext); this.mSeekBar.setOnSeekBarChangeListener(this); layout.addView(this.mSeekBar, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); if (shouldPersist()) { this.mValue = getPersistedInt(this.mDefault); } // mSeekBar.setProgress(mValue); return layout; }
74. ViewImageConsumer#isMatchingParentButNotMeasured()
Project: enroscar
File: ViewImageConsumer.java
File: ViewImageConsumer.java
@Override public boolean isMatchingParentButNotMeasured() { final View view = this.view; final LayoutParams params = view.getLayoutParams(); if (params == null) { return false; } return params.width == LayoutParams.MATCH_PARENT && view.getWidth() == 0 || params.height == LayoutParams.MATCH_PARENT && view.getHeight() == 0; }
75. ViewImageConsumer#getTargetWidth()
Project: enroscar
File: ViewImageConsumer.java
File: ViewImageConsumer.java
@Override protected int getTargetWidth() { final View view = this.view; final LayoutParams params = view.getLayoutParams(); if (params == null || params.width == LayoutParams.WRAP_CONTENT) { return -1; } final int w = view.getWidth(); return w > 0 ? w : params.width; }
76. ViewImageConsumer#getTargetHeight()
Project: enroscar
File: ViewImageConsumer.java
File: ViewImageConsumer.java
@Override protected int getTargetHeight() { final View view = this.view; final LayoutParams params = view.getLayoutParams(); if (params == null || params.height == LayoutParams.WRAP_CONTENT) { return -1; } final int h = view.getHeight(); return h > 0 ? h : params.height; }
77. BitmapFactoryUtils#calcDecodeSizeHint()
Project: droidparts
File: BitmapFactoryUtils.java
File: BitmapFactoryUtils.java
public static Point calcDecodeSizeHint(ImageView imageView) { Point p = new Point(); LayoutParams params = imageView.getLayoutParams(); p.x = (params != null) ? params.width : imageView.getWidth(); p.y = (params != null) ? params.height : imageView.getHeight(); return p; }
78. M_TextInput#getView()
Project: droidar
File: M_TextInput.java
File: M_TextInput.java
@Override public View getView(Context context) { LinearLayout container = new LinearLayout(context); container.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); container.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfDescription); LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfInputText); if (isLongText()) { int m = 8; p2.setMargins(2 * m, m, 2 * m, m); container.setOrientation(LinearLayout.VERTICAL); } TextView nameText = new TextView(context); nameText.setText(getVarName()); nameText.setLayoutParams(p); container.addView(nameText); editText = new EditText(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (horizontalScrollable) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onTouchEvent(event); } }; editText.setLayoutParams(p2); editText.setText(load()); editText.setEnabled(editable); editText.setFocusable(editable); editText.setFocusableInTouchMode(editable); setInfoText(additionalInfoText); if (isHorizontalScrollable()) { editText.setHorizontallyScrolling(true); } container.addView(editText); if (myDecorator != null) { int currentLevel = myDecorator.getCurrentLevel(); myDecorator.decorate(context, nameText, currentLevel + 1, UiDecorator.TYPE_INFO_TEXT); myDecorator.decorate(context, editText, currentLevel + 1, UiDecorator.TYPE_EDIT_TEXT); } return container; }
79. M_Spinner#getView()
Project: droidar
File: M_Spinner.java
File: M_Spinner.java
@Override public View getView(Context context) { LinearLayout container = new LinearLayout(context); container.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); container.setGravity(Gravity.CENTER_VERTICAL); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfDescription); LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, weightOfSpinner); TextView nameText = new TextView(context); nameText.setText(getVarName()); nameText.setLayoutParams(p); container.addView(nameText); s = new Spinner(context); s.setLayoutParams(p2); ArrayAdapter<SpinnerItem> a = new ArrayAdapter<SpinnerItem>(context, android.R.layout.simple_spinner_item, loadListToDisplay()); a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s.setAdapter(a); s.setPrompt(getVarName()); setEditable(isEditable()); setSelectedItemId(loadSelectedItemId()); if (selectedItemPos != 0) { selectInSpinner(selectedItemPos); } container.addView(s); return container; }
80. M_ImageGallery#getView()
Project: droidar
File: M_ImageGallery.java
File: M_ImageGallery.java
@Override public View getView(final Context context) { LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); LinearLayout l = new LinearLayout(context); l.setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); l.setOrientation(LinearLayout.VERTICAL); TextView t = new TextView(context); t.setGravity(Gravity.CENTER_HORIZONTAL); t.setText(getVarName()); l.addView(t); final Gallery g = new Gallery(context); g.setLayoutParams(p); g.setSpacing(10); // g.setUnselectedAlpha(0.1f); r = getImageIds(); // TypedArray a = obtainStyledAttributes(android.R.style.Theme); // mGalleryItemBackground = a.getResourceId( // android.R.styleable.Theme_galleryItemBackground, 0); // a.recycle(); g.setAdapter(new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView iv; if (convertView instanceof ImageView) { iv = (ImageView) convertView; } else { iv = new ImageView(context); iv.setLayoutParams(new Gallery.LayoutParams(64, 64)); iv.setScaleType(ImageView.ScaleType.FIT_XY); } iv.setImageResource(r.get(position)); return iv; } @Override public long getItemId(int position) { return position; } @Override public Object getItem(int position) { return position; } @Override public int getCount() { return r.size(); } }); g.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View item, int position, long id) { selectedItemNr = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); myDecorator.decorate(context, l, level + 1, UiDecorator.TYPE_CONTAINER); myDecorator.decorate(context, t, level + 1, UiDecorator.TYPE_INFO_TEXT); } l.addView(g); return l; }
81. M_Container#getView()
Project: droidar
File: M_Container.java
File: M_Container.java
@Override public View getView(Context target) { LinearLayout containerForAllItems = new LinearLayout(target); ScrollView scrollContainer = new ScrollView(target); LinearLayout mostOuterBox = new LinearLayout(target); LayoutParams layParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); containerForAllItems.setLayoutParams(layParams); containerForAllItems.setPadding(MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING); containerForAllItems.setOrientation(LinearLayout.VERTICAL); scrollContainer.setLayoutParams(layParams); scrollContainer.addView(containerForAllItems); mostOuterBox.setGravity(Gravity.CENTER); mostOuterBox.setBackgroundColor(OUTER_BACKGROUND_DIMMING_COLOR); mostOuterBox.setPadding(MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING); mostOuterBox.addView(scrollContainer); BACKGROUND.applyTo(scrollContainer); if (myDecorator != null) { int level = myDecorator.getCurrentLevel(); myDecorator.decorate(target, mostOuterBox, level + 1, UiDecorator.TYPE_CONTAINER); myDecorator.decorate(target, scrollContainer, level + 2, UiDecorator.TYPE_CONTAINER); myDecorator.setCurrentLevel(level + 3); } createViewsForAllModifiers(target, containerForAllItems); if (myDecorator != null) { /* * Then reduce level again to the previous value */ myDecorator.setCurrentLevel(myDecorator.getCurrentLevel() - 3); } return mostOuterBox; }
82. SimpleRatingBar#initSimpleRatingBarSpecificViewParamsForTheTextView()
Project: droidar
File: SimpleRatingBar.java
File: SimpleRatingBar.java
private void initSimpleRatingBarSpecificViewParamsForTheTextView() { int completeHeigth = DEFAULT_HEIGTH_PER_LINE_IN_DIP * items.size(); LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, dipToPixels(completeHeigth)); setLayoutParams(p); setGravity(Gravity.CENTER_HORIZONTAL); setShadowLayer(SHADOW_LAYER_SIZE, 1, 1, Color.BLACK); setPadding(DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING); }
83. SimpleUIv1#generateViewFor()
Project: droidar
File: SimpleUIv1.java
File: SimpleUIv1.java
private static LinearLayout generateViewFor(Activity target, EditItem o, Object optionalMessage, UIConfig config) { ModifierGroup group = new ModifierGroup(); Theme configTheme = config.loadTheme(); if (configTheme != null) { group.setTheme(configTheme); } o.customizeScreen(group, optionalMessage); group.addModifier(config.loadCloseButtonsFor(target, group)); LayoutParams layParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); LinearLayout containerForAllItems = new LinearLayout(target); containerForAllItems.setLayoutParams(layParams); containerForAllItems.setPadding(MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING); containerForAllItems.setOrientation(LinearLayout.VERTICAL); containerForAllItems.addView(group.getView(target)); if (group.getTheme() != null) { group.getTheme().applyOuter1(containerForAllItems); } LinearLayout mostOuterBox = new LinearLayout(target); mostOuterBox.setGravity(Gravity.CENTER); mostOuterBox.setBackgroundColor(OUTER_BACKGROUND_DIMMING_COLOR); mostOuterBox.setPadding(MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING, MOST_OUTER_PADDING); mostOuterBox.addView(containerForAllItems); return mostOuterBox; }
84. ListModifier#getView()
Project: droidar
File: ListModifier.java
File: ListModifier.java
@Override public View getView(final Context context) { LinearLayout listControls = new LinearLayout(context); listControls.setGravity(Gravity.CENTER_HORIZONTAL); for (String itemType : myItemTypes) { listControls.addView(newItemAddButton(context, itemType)); } if (myItemsDeletable) { Button clearButton = new Button(context); clearButton.setText(CLEAR_LIST_TEXT); clearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { clearList(); } }); listControls.addView(clearButton); } LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); myListView = new LinearLayout(context); myListView.setOrientation(LinearLayout.VERTICAL); myListView.setLayoutParams(p); myList = getListItems(); for (int i = 0; i < myList.size(); i++) { addListItemView(myListView, myList.get(i), i, context); } LinearLayout listView = new LinearLayout(context); listView.setOrientation(LinearLayout.VERTICAL); LinearLayout scrollContainer = new LinearLayout(context); scrollContainer.setLayoutParams(p); scrollContainer.setGravity(Gravity.CENTER_HORIZONTAL); HorizontalScrollView scroller = new HorizontalScrollView(context); scroller.addView(listControls); scrollContainer.addView(scroller); listView.addView(scrollContainer); listView.addView(myListView); listView.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); listControls.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); myListView.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); if (getTheme() != null) { getTheme().applyOuter1(listView); getTheme().applyOuter2(listControls); getTheme().applyOuter2(myListView); } return listView; }
85. ImageModifier#getView()
Project: droidar
File: ImageModifier.java
File: ImageModifier.java
@Override public View getView(final Context context) { LayoutParams p = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1); LinearLayout l = new LinearLayout(context); l.setPadding(SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING, SimpleUIv1.DEFAULT_PADDING); l.setOrientation(LinearLayout.VERTICAL); TextView t = new TextView(context); t.setGravity(Gravity.CENTER_HORIZONTAL); t.setText(getVarName()); l.addView(t); final Gallery g = new Gallery(context); g.setLayoutParams(p); g.setSpacing(10); // g.setUnselectedAlpha(0.1f); r = getImageIds(); // TypedArray a = obtainStyledAttributes(android.R.style.Theme); // mGalleryItemBackground = a.getResourceId( // android.R.styleable.Theme_galleryItemBackground, 0); // a.recycle(); g.setAdapter(new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView iv; if (convertView instanceof ImageView) { iv = (ImageView) convertView; } else { iv = new ImageView(context); iv.setLayoutParams(new Gallery.LayoutParams(64, 64)); iv.setScaleType(ImageView.ScaleType.FIT_XY); } iv.setImageResource(r.get(position)); return iv; } @Override public long getItemId(int position) { return position; } @Override public Object getItem(int position) { return position; } @Override public int getCount() { return r.size(); } }); g.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View item, int position, long id) { selectedItemNr = position; } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); l.addView(g); if (getTheme() != null) { getTheme().applyOuter1(l); getTheme().applyNormal1(g); getTheme().applyOuter2(t); } return l; }
86. ImageButtonModifier#getView()
Project: droidar
File: ImageButtonModifier.java
File: ImageButtonModifier.java
@Override public View getView(Context context) { l = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); l.setLayoutParams(params); b = new ImageButton(context); b.setLayoutParams(params); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ImageButtonModifier.this.onClick(); } }); b.setImageResource(myText); if (getTheme() != null) getTheme().applyNormal1(b); int p = 6; b.setPadding(p, p, p, p); l.addView(b); int p2 = 2; l.setPadding(p2, p2, p2, p2); return l; }
87. ButtonModifier#getView()
Project: droidar
File: ButtonModifier.java
File: ButtonModifier.java
@Override public View getView(Context context) { LinearLayout l = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); l.setLayoutParams(params); Button b = new Button(context); b.setLayoutParams(params); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ButtonModifier.this.onClick(); } }); b.setText(myText); if (getTheme() != null) getTheme().applyNormal1(b); int p = 12; b.setPadding(p, p, p, p); l.addView(b); int p2 = 4; l.setPadding(p2, p2, p2, p2); return l; }
88. MarkerDetectionSetup#initializeCamera()
Project: droidar
File: MarkerDetectionSetup.java
File: MarkerDetectionSetup.java
@Override public void initializeCamera() { MarkerObjectMap markerObjectMap = new MarkerObjectMap(); DisplayMetrics displayMetrics = myTargetActivity.getResources().getDisplayMetrics(); int weight = displayMetrics.widthPixels; int height = displayMetrics.heightPixels; int apiLevel = Integer.parseInt(android.os.Build.VERSION.SDK); Camera mCamera = Camera.open(); Camera.Parameters parameters = mCamera.getParameters(); cameraSize = parameters.getPreviewSize(); // Check the OS version to determine what kind of preview to use. if (apiLevel < 5) { weight = preSdkV5(height); } else { weight = postSdkV5(parameters, weight, height); } optimalLayoutParams = new LayoutParams(weight, height); mCamera.release(); tryToLoadCameraSettings(); // initialize native code. int[] constants = new int[2]; nativeLib.initThread(constants, calib.cameraMatrix, calib.distortionMatrix); myThread = new DetectionThread(nativeLib, myGLSurfaceView, markerObjectMap, _a2_getUnrecognizedMarkerListener()); if (apiLevel <= 5) { cameraPreview = new PreviewPre2_0(myTargetActivity, myThread, cameraSize); Log.d("AR", "API Level: " + apiLevel + " Created Preview Pre2.1"); } else { cameraPreview = new PreviewPost2_0(myTargetActivity, myThread, cameraSize); Log.d("AR", "API Level: " + apiLevel + " Created Preview Post2.1"); } _a3_registerMarkerObjects(markerObjectMap); }
89. CodeLayout#onCreate()
Project: codeexamples-android
File: CodeLayout.java
File: CodeLayout.java
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutParams params1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); TextView text = new TextView(this); text.setText("Hello"); text.setLayoutParams(params1); EditText edit = new EditText(this); edit.setHint("This is your input..."); edit.setLayoutParams(params1); Button button = new Button(this); button.setText("Press me"); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast makeText = Toast.makeText(v.getContext(), "Pressed", 200); makeText.show(); } }); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(10, 10, 10, 10); layout.addView(text); layout.addView(edit); layout.addView(button); setContentView(layout); }
90. RatioDrawable#adjust()
Project: BeeFramework_Android
File: RatioDrawable.java
File: RatioDrawable.java
private void adjust(ImageView iv, Bitmap bm, boolean done) { int vw = getWidth(iv); if (vw <= 0) return; int dw = bm.getWidth(); int dh = bm.getHeight(); int th = targetHeight(dw, dh, vw) + iv.getPaddingTop() + iv.getPaddingBottom(); LayoutParams lp = iv.getLayoutParams(); if (lp == null) return; int vh = lp.height; if (th != vh) { lp.height = th; iv.setLayoutParams(lp); } if (done) adjusted = true; }
91. ProfileActivity#onCreate()
Project: BeeFramework_Android
File: ProfileActivity.java
File: ProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.profile_list); title = (TextView) findViewById(R.id.topview_title); back = (ImageView) findViewById(R.id.topview_back); listView = (ListView) findViewById(R.id.profile_shots_list); Intent intent = getIntent(); playerId = intent.getIntExtra(PLAYER_ID, 1); title.setText("????"); back.setVisibility(View.VISIBLE); back.setOnClickListener(this); headView = LayoutInflater.from(this).inflate(R.layout.profile, null); bottomView = LayoutInflater.from(this).inflate(R.layout.profile_bottom, null); head = (ImageView) headView.findViewById(R.id.profile_head); name = (TextView) headView.findViewById(R.id.profile_name); location = (TextView) headView.findViewById(R.id.profile_location); net = (TextView) headView.findViewById(R.id.profile_net); shots_count = (TextView) headView.findViewById(R.id.profile_shots_count); likes_count = (TextView) headView.findViewById(R.id.profile_likes_count); following_count = (TextView) headView.findViewById(R.id.profile_following_count); followers_count = (TextView) headView.findViewById(R.id.profile_followers_count); shots_view = (LinearLayout) headView.findViewById(R.id.profile_shots_view); likes_view = (LinearLayout) headView.findViewById(R.id.profile_likes_view); following_view = (LinearLayout) headView.findViewById(R.id.profile_following_view); followers_view = (LinearLayout) headView.findViewById(R.id.profile_followers_view); more = (LinearLayout) bottomView.findViewById(R.id.profile_bottom_more); LayoutParams params = head.getLayoutParams(); params.width = getWindowManager().getDefaultDisplay().getWidth() / 4; params.height = params.width; head.setLayoutParams(params); listView.addHeaderView(headView); listView.addFooterView(bottomView); head.setOnClickListener(this); shots_view.setOnClickListener(this); likes_view.setOnClickListener(this); following_view.setOnClickListener(this); followers_view.setOnClickListener(this); more.setOnClickListener(this); playerModel = new PlayerModel(this); playerModel.addResponseListener(this); playerModel.getPlayer(playerId); playerModel.getProfileShotList(playerId); }
92. VideoView#setSurfaceLayout()
Project: BambooPlayer
File: VideoView.java
File: VideoView.java
private void setSurfaceLayout(float userRatio, int videoWidth, int videoHeight, float videoAspectRatio) { LayoutParams lp = getLayoutParams(); Display disp = mActivity.getWindowManager().getDefaultDisplay(); int windowWidth = disp.getWidth(); int windowHeight = disp.getHeight(); float windowRatio = windowWidth / (float) windowHeight; float videoRatio = userRatio <= 0.01f ? videoAspectRatio : userRatio; mSurfaceHeight = videoHeight; mSurfaceWidth = videoWidth; if (VIDEO_LAYOUT_ORIGIN == mVideoMode && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) { lp.width = (int) (mSurfaceHeight * videoRatio); lp.height = mSurfaceHeight; } else if (mVideoMode == VIDEO_LAYOUT_ZOOM) { lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight); lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio); } else if (mVideoMode == VIDEO_LAYOUT_SCALE_ZOOM && mVideoHeight > 0) { lp.width = (int) (mVideoHeight * videoRatio); lp.height = mVideoHeight; } else { boolean full = mVideoMode == VIDEO_LAYOUT_STRETCH; lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight); lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio); } mVideoHeight = lp.height; setLayoutParams(lp); getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight); }
93. UploadPhotoResultDialog#onCreate()
Project: astrid
File: UploadPhotoResultDialog.java
File: UploadPhotoResultDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.upload_photo_response); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mOutput = (TextView) findViewById(R.id.apiOutput); mUsefulTip = (TextView) findViewById(R.id.usefulTip); mViewPhotoButton = (Button) findViewById(R.id.view_photo_button); mTagPhotoButton = (Button) findViewById(R.id.tag_photo_button); mUploadedPhoto = (ImageView) findViewById(R.id.uploadedPhoto); JSONObject json; try { json = Util.parseJson(response); final String photo_id = json.getString("id"); this.photo_id = photo_id; mOutput.setText(json.toString(2)); mUsefulTip.setText(activity.getString(R.string.photo_tip)); Linkify.addLinks(mUsefulTip, Linkify.WEB_URLS); mViewPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hidePhoto) { mViewPhotoButton.setText(R.string.view_photo); hidePhoto = false; mUploadedPhoto.setImageBitmap(null); } else { hidePhoto = true; mViewPhotoButton.setText(R.string.hide_photo); /* * Source tag: view_photo_tag */ Bundle params = new Bundle(); params.putString("fields", "picture"); dialog = ProgressDialog.show(activity, "", activity.getString(R.string.please_wait), true, true); dialog.show(); Utility.mAsyncRunner.request(photo_id, params, new ViewPhotoRequestListener()); } } }); mTagPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: tag_photo_tag */ setTag(); } }); } catch (JSONException e) { setText(activity.getString(R.string.exception) + e.getMessage()); } catch (FacebookError e) { setText(activity.getString(R.string.facebook_error) + e.getMessage()); } }
94. UpdateStatusResultDialog#onCreate()
Project: astrid
File: UpdateStatusResultDialog.java
File: UpdateStatusResultDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.update_post_response); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mOutput = (TextView) findViewById(R.id.apiOutput); mOutput.setText(values.toString()); mUsefulTip = (TextView) findViewById(R.id.usefulTip); mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance()); mViewPostButton = (Button) findViewById(R.id.view_post_button); mDeletePostButton = (Button) findViewById(R.id.delete_post_button); final String postId = values.getString("post_id"); mViewPostButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: view_post_tag */ Utility.mAsyncRunner.request(postId, new WallPostRequestListener()); } }); mDeletePostButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: delete_post_tag */ Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE", new WallPostDeleteListener(), null); } }); }
95. PermissionsDialog#onCreate()
Project: astrid
File: PermissionsDialog.java
File: PermissionsDialog.java
/* * Layout the permission dialog */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.permissions_list); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mPermissionDetails = (TextView) findViewById(R.id.permission_detail); mPermissionDetails.setMovementMethod(LinkMovementMethod.getInstance()); userPermissionsList = (ListView) findViewById(R.id.user_permissions_list); friendPermissionsList = (ListView) findViewById(R.id.friend_permissions_list); extendedPermissionsList = (ListView) findViewById(R.id.extended_permissions_list); userPermissionsAdapter = new PermissionsListAdapter(user_permissions); userPermissionsList.setAdapter(userPermissionsAdapter); friendPermissionsAdapter = new PermissionsListAdapter(friend_permissions); friendPermissionsList.setAdapter(friendPermissionsAdapter); extendedPermissionAdapter = new PermissionsListAdapter(extended_permissions); extendedPermissionsList.setAdapter(extendedPermissionAdapter); TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); TabSpec spec1 = tabHost.newTabSpec("Tab 1"); spec1.setIndicator(activity.getString(R.string.user)); spec1.setContent(R.id.user_permissions_list); TabSpec spec2 = tabHost.newTabSpec("Tab 2"); spec2.setIndicator(activity.getString(R.string.friend)); spec2.setContent(R.id.friend_permissions_list); TabSpec spec3 = tabHost.newTabSpec("Tab 3"); spec3.setIndicator(activity.getString(R.string.extended)); spec3.setContent(R.id.extended_permissions_list); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.addTab(spec3); tabHost.setCurrentTab(0); tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = TAB_HEIGHT; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = TAB_HEIGHT; tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = TAB_HEIGHT; mGetPermissions = (Button) findViewById(R.id.get_permissions_button); mGetPermissions.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source Tag: perms_tag Call authorize to get the new * permissions */ if (reqPermVector.isEmpty() && Utility.mFacebook.isSessionValid()) { Toast.makeText(activity.getBaseContext(), "No Permissions selected.", Toast.LENGTH_SHORT).show(); PermissionsDialog.this.dismiss(); } else { String[] permissions = reqPermVector.toArray(new String[0]); Utility.mFacebook.authorize(activity, permissions, new LoginDialogListener()); } } }); }
96. FQLQuery#onCreate()
Project: astrid
File: FQLQuery.java
File: FQLQuery.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.fql_query); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mFQLQuery = (EditText) findViewById(R.id.fqlquery); mFQLOutput = (TextView) findViewById(R.id.fqlOutput); mSubmitButton = (Button) findViewById(R.id.submit_button); mSubmitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0); dialog = ProgressDialog.show(FQLQuery.this.activity, "", FQLQuery.this.activity.getString(R.string.please_wait), true, true); /* * Source tag: fql_query_tag */ String query = mFQLQuery.getText().toString(); Bundle params = new Bundle(); params.putString("method", "fql.query"); params.putString("query", query); Utility.mAsyncRunner.request(null, params, new FQLRequestListener()); } }); }
97. FieldsConnectionsDialog#onCreate()
Project: astrid
File: FieldsConnectionsDialog.java
File: FieldsConnectionsDialog.java
/* * Layout the dialog */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fields_connections_list); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); fieldsList = (ListView) findViewById(R.id.fields_list); connectionsList = (ListView) findViewById(R.id.connections_list); fieldsAdapter = new FieldsListAdapter(); if (this.fieldsArray == null) { fieldsList.setAdapter(new ArrayAdapter<String>(explorerActivity, android.R.layout.simple_list_item_1, new String[] { "No fields available" })); } else { fieldsList.setAdapter(fieldsAdapter); } connectionsAdapter = new ConnectionsListAdapter(); if (this.connectionsArray == null) { connectionsList.setAdapter(new ArrayAdapter<String>(explorerActivity, android.R.layout.simple_list_item_1, new String[] { "No connections available" })); } else { connectionsList.setAdapter(connectionsAdapter); } TabHost tabHost = (TabHost) findViewById(R.id.tabHost); tabHost.setup(); TabSpec spec1 = tabHost.newTabSpec("Tab 1"); spec1.setIndicator(explorerActivity.getString(R.string.fields)); spec1.setContent(R.id.fields_layout); TabSpec spec2 = tabHost.newTabSpec("Tab 2"); spec2.setIndicator(explorerActivity.getString(R.string.connections)); spec2.setContent(R.id.connections_list); tabHost.addTab(spec1); tabHost.addTab(spec2); tabHost.setCurrentTab(0); tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = TAB_HEIGHT; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = TAB_HEIGHT; mGetFieldsButton = (Button) findViewById(R.id.get_fields_button); mGetFieldsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source Tag: */ FieldsConnectionsDialog.this.dismiss(); if (!fieldsVector.isEmpty()) { explorerActivity.getFields(fieldsVector); } else { Toast.makeText(explorerActivity.getBaseContext(), "No Fields selected.", Toast.LENGTH_SHORT).show(); } } }); connectionsList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { FieldsConnectionsDialog.this.dismiss(); explorerActivity.getConnection(connectionsArray.get(position)); } }); }
98. PopupControlSet#buildDialog()
Project: astrid
File: PopupControlSet.java
File: PopupControlSet.java
protected Dialog buildDialog(String title, final PopupDialogClickListener okClickListener, DialogInterface.OnCancelListener cancelClickListener) { int theme = ThemeService.getEditDialogTheme(); dialog = new Dialog(activity, theme); if (title.length() == 0) dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); else dialog.setTitle(title); View v = getView(); dialog.setContentView(v, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Button dismiss = (Button) v.findViewById(R.id.edit_dlg_ok); if (dismiss != null) { dismiss.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (okClickListener.onClick(dialog, 0)) DialogUtilities.dismissDialog(activity, dialog); } }); } LayoutParams params = dialog.getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.WRAP_CONTENT; if (AndroidUtilities.isTabletSized(activity)) { DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_HEIGHT) params.width = (3 * metrics.widthPixels) / 5; else if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_WIDTH) params.width = (4 * metrics.widthPixels) / 5; } dialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); dialog.setOnCancelListener(cancelClickListener); dialog.setOwnerActivity(PopupControlSet.this.activity); additionalDialogSetup(); return dialog; }
99. TaskAdapter#showEditNotesDialog()
Project: astrid
File: TaskAdapter.java
File: TaskAdapter.java
private void showEditNotesDialog(final Task task) { String notes = null; Task t = taskService.fetchById(task.getId(), Task.NOTES); if (t != null) notes = t.getValue(Task.NOTES); if (TextUtils.isEmpty(notes)) return; int theme = ThemeService.getEditDialogTheme(); final Dialog dialog = new Dialog(fragment.getActivity(), theme); dialog.setTitle(R.string.TEA_note_label); View notesView = LayoutInflater.from(fragment.getActivity()).inflate(R.layout.notes_view_dialog, null); dialog.setContentView(notesView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); notesView.findViewById(R.id.edit_dlg_ok).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); final TextView notesField = (TextView) notesView.findViewById(R.id.notes); notesField.setText(notes); LayoutParams params = dialog.getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.WRAP_CONTENT; Configuration config = fragment.getResources().getConfiguration(); int size = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (AndroidUtilities.getSdkVersion() >= 9 && size == Configuration.SCREENLAYOUT_SIZE_XLARGE) { DisplayMetrics metrics = fragment.getResources().getDisplayMetrics(); params.width = metrics.widthPixels / 2; } dialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); dialog.show(); }
100. TransitionCompat#endSharedElementAnimation()
Project: AndroidStudyDemo
File: TransitionCompat.java
File: TransitionCompat.java
/** * ?????? * ?????????????????????????????????? * @param activity * @param layoutResId */ private static void endSharedElementAnimation(final Activity activity, int layoutResId) { final View orginalView = getSharedElementOrginalView(activity, layoutResId); if (orginalView == null) { return; } View currentView = activity.findViewById(mSharedElementId); currentView.setVisibility(View.INVISIBLE); if (!ActivityOptionsCompatICS.isInScreen(activity, currentView)) { //?????????????????????? return; } Rect orginalBounds = new Rect(); orginalBounds.set(Position.getGlobalVisibleRect(currentView)); final int finalOffsetY; boolean isFinalFullScreen = ActivityOptionsCompatICS.isFullScreen(activity); if (mIsStartFullScreen == false && isFinalFullScreen == true) { finalOffsetY = ActivityOptionsCompatICS.getStatusBarHeight(activity); } else { finalOffsetY = 0; } LayoutParams orginalParams = new LayoutParams(orginalBounds.width(), orginalBounds.height()); ViewGroup rootView = (ViewGroup) (activity.getWindow().getDecorView()); rootView.addView(orginalView, orginalParams); orginalView.setX(orginalBounds.left); orginalView.setY(orginalBounds.top); /** * ????view????? */ final Rect targetBounds = new Rect(mStartX, mStartY, mStartX + mWidth, mStartY + mHeight); final ViewAnim anim = new ViewAnim(); anim.setDuration(mAnimTime); anim.setStartDelay(mStartDelay); //???????????? anim.addListener(mViewAnimListener); anim.setTimeInterpolator(mInterpolator); orginalView.post(new Runnable() { @Override public void run() { anim.startViewTweensAnim(orginalView, targetBounds, 0, finalOffsetY); } }); }