private LinearLayout.LayoutParams getLayoutParams(float factor) { float baselineSize = 300; float size = baselineSize * factor; return new LinearLayout.LayoutParams((int)size, (int)size); }
private LinearLayout.LayoutParams getLayoutParams(float factor) { float size = BASELINE_SIZE * factor; return new LinearLayout.LayoutParams((int)size, (int)size); }
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { ViewGroup.LayoutParams old=thingToResize.getLayoutParams(); ViewGroup.LayoutParams current=new LinearLayout.LayoutParams(64+progress, old.height); thingToResize.setLayoutParams(current); }
private void initView(Context context) { mContext = context; LinearLayout moreView = (LinearLayout)LayoutInflater.from(mContext).inflate(R.layout.smoothlistview_footer, null); addView(moreView); moreView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); mContentView = moreView.findViewById(R.id.smoothlistview_footer_content); mProgressBar = moreView.findViewById(R.id.smoothlistview_footer_progressbar); mHintView = (TextView)moreView.findViewById(R.id.smoothlistview_footer_hint_textview); }
public void setData(List<String>... data) { if (data != null && data.length > 0) { for (int i = 0; i < data.length; i++) { List<String> list = data[i]; ChildView childView = new ChildView(mContext); LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT); params.weight = 1; childView.setLayoutParams(params); childView.setData(list); childView.setTag(i); addView(childView); } } }
/** * build the sticky footer item view * * @return */ public static ViewGroup buildStickyDrawerItemFooter(Context ctx, DrawerBuilder drawer, View.OnClickListener onClickListener) { //create the container view final LinearLayout linearLayout = new LinearLayout(ctx); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); //set the background color to the drawer background color (if it has alpha the shadow won't be visible) linearLayout.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_background, R.color.material_drawer_background)); //create the divider if (drawer.mStickyFooterDivider) { addStickyFooterDivider(ctx, linearLayout); } fillStickyDrawerItemFooter(drawer, linearLayout, onClickListener); return linearLayout; }
private void addTab(int index, CharSequence text, int iconResId) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index; tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (iconResId != 0) { tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); } mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1)); }
/** * Create layout that will be a container for animation elements * * @return Configured container for animation elements (LinearLayout) */ protected LinearLayout createAndPrepareFoldingContainer() { LinearLayout foldingContainer = new LinearLayout(getContext()); foldingContainer.setClipToPadding(false); foldingContainer.setClipChildren(false); foldingContainer.setOrientation(LinearLayout.VERTICAL); foldingContainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); return foldingContainer; }
private void addTabDivider() { View divider = new View(getContext()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { mViewPager.setBackgroundColor(getContext().getResources().getColor(R.color.horizontal_vertical)); } else { mViewPager.setBackgroundColor(getContext().getColor(R.color.horizontal_vertical)); } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT); mTabsContainer.addView(divider, mTabsContainer.getChildCount() - 2, params); }
public MultiItemRowListAdapter(Context context, ListAdapter adapter, int itemsPerRow, int cellSpacing) { if (itemsPerRow <= 0) { throw new IllegalArgumentException("Number of items per row must be positive"); } mContextReference = new WeakReference<Context>(context); mAdapter = adapter; mItemsPerRow = itemsPerRow; mCellSpacing = cellSpacing; mItemLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT); mItemLayoutParams.setMargins(cellSpacing, cellSpacing, 0, 0); mItemLayoutParams.weight = 1; mRowLayoutParams = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
@SuppressLint("InflateParams") private void initView(Context context) { mContext = context; LinearLayout moreView = (LinearLayout) LayoutInflater.from(mContext) .inflate(R.layout.xlistview_footer, null); addView(moreView); moreView.setLayoutParams(new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); mContentView = moreView.findViewById(R.id.xlistview_footer_content); mProgressBar = moreView.findViewById(R.id.xlistview_footer_progressbar); mHintView = (TextView) moreView .findViewById(R.id.xlistview_footer_hint_textview); }
private void initializeSocialSentenceView(Context context) { socialSentenceView = new TextView(context); socialSentenceView.setTextSize( TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_likeview_text_size)); socialSentenceView.setMaxLines(2); socialSentenceView.setTextColor(foregroundColor); socialSentenceView.setGravity(Gravity.CENTER); LinearLayout.LayoutParams socialSentenceViewLayout = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); socialSentenceView.setLayoutParams(socialSentenceViewLayout); }
private void initializeLikeCountView(Context context) { likeBoxCountView = new LikeBoxCountView(context); LinearLayout.LayoutParams likeCountViewLayout = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); likeBoxCountView.setLayoutParams(likeCountViewLayout); }
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { ViewGroup.LayoutParams old=thingToResize.getLayoutParams(); ViewGroup.LayoutParams current=new LinearLayout.LayoutParams(old.width, 64+progress); thingToResize.setLayoutParams(current); }
private void init() { LayoutInflater.from(getContext()).inflate(R.layout.view_context_menu, this, true); setBackgroundResource(R.drawable.bg_container_shadow); setOrientation(VERTICAL); setLayoutParams(new LayoutParams(CONTEXT_MENU_WIDTH, ViewGroup.LayoutParams.WRAP_CONTENT)); }
private void initializeViews() { int width = isTabletMode ? LayoutParams.WRAP_CONTENT : LayoutParams.MATCH_PARENT; int height = isTabletMode ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT; LayoutParams params = new LayoutParams(width, height); setLayoutParams(params); setOrientation(isTabletMode ? HORIZONTAL : VERTICAL); View rootView = inflate(getContext(), isTabletMode ? R.layout.bb_bottom_bar_item_container_tablet : R.layout.bb_bottom_bar_item_container, this); rootView.setLayoutParams(params); backgroundOverlay = rootView.findViewById(R.id.bb_bottom_bar_background_overlay); outerContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_outer_container); tabContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_item_container); shadowView = findViewById(R.id.bb_bottom_bar_shadow); }
/** * adds the shadow to the stickyFooter * * @param ctx * @param footerView */ private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) { LinearLayout divider = new LinearLayout(ctx); LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx)); divider.setOrientation(LinearLayout.VERTICAL); divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider)); footerView.addView(divider, dividerParams); }
private LinearLayout.LayoutParams getDefultlayoutParams(){ int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(height, ViewGroup.LayoutParams.WRAP_CONTENT); return layoutParams; }
@Before public void setUp() { sdkVersion = Build.VERSION.SDK_INT; MockitoAnnotations.initMocks(this); activity = Robolectric.buildActivity(Activity.class).create().start().postCreate(null).resume(); view = new View(activity.get()); target = new TestViewTarget(view); attachStateTarget = new AttachStateTarget(view); LinearLayout linearLayout = new LinearLayout(activity.get()); View expandView = new View(activity.get()); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, /*height=*/ 0); linearLayoutParams.weight = 1f; expandView.setLayoutParams(linearLayoutParams); linearLayout.addView(expandView); parent = new FrameLayout(activity.get()); parent.addView(view); linearLayout.addView(parent); activity.get().setContentView(linearLayout); }
@Test public void getLayoutParams_shouldReturnTheSameLinearLayoutParamsFromTheSetter() throws Exception { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 2); linearLayout.setLayoutParams(params); assertSame(params, linearLayout.getLayoutParams()); }