Java Code Examples for android.view.ViewGroup
The following examples show how to use
android.view.ViewGroup. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: MediaChooser Source File: VideoFragment.java License: Apache License 2.0 | 6 votes |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mView == null) { mView = inflater.inflate(R.layout.view_grid_layout_media_chooser, container, false); getActivity().getWindow().setBackgroundDrawable(null); mVideoGridView = (GridView) mView.findViewById(R.id.gridViewFromMediaChooser); if (getArguments() != null) { initVideos(getArguments().getString("name")); } else { initVideos(); } } else { if (mView.getParent() != null) { ((ViewGroup) mView.getParent()).removeView(mView); } if (mVideoAdapter == null || mVideoAdapter.getCount() == 0) { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } } return mView; }
Example 2
Source Project: smooth-app-bar-layout Source File: ScrollFlag.java License: Apache License 2.0 | 6 votes |
public ScrollFlag(AppBarLayout layout) { if (layout != null) { int i = 0; for (int z = layout.getChildCount(); i < z; ++i) { View child = layout.getChildAt(i); ViewGroup.LayoutParams layoutParams = child.getLayoutParams(); if (layoutParams instanceof AppBarLayout.LayoutParams) { AppBarLayout.LayoutParams childLp = (AppBarLayout.LayoutParams) layoutParams; int flags = childLp.getScrollFlags(); if ((flags & AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL) != 0) { vView = child; mFlags = flags; break; } } } } }
Example 3
Source Project: iGap-Android Source File: FragmentShowImage.java License: GNU Affero General Public License v3.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { realmShowImage = Realm.getDefaultInstance(); //View view = inflater.inflate(R.layout.activity_show_image, container, false); //exitFragmentTransition = FragmentTransition.with(this).duration(200).interpolator(new LinearOutSlowInInterpolator()).to(view.findViewById(R.id.asi_view_pager)).start(savedInstanceState); // //exitFragmentTransition.exitListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationStart(Animator animation) { // Log.d("FFFFFFF", "onAnimationStart: "); // } // // @Override // public void onAnimationEnd(Animator animation) { // Log.d("FFFFFFF", "onAnimationEnd: "); // } //}).interpolator(new FastOutSlowInInterpolator()); //exitFragmentTransition.startExitListening(view.findViewById(R.id.rooShowImage)); return inflater.inflate(R.layout.activity_show_image, container, false); }
Example 4
Source Project: Telegram-FOSS Source File: FloatingToolbar.java License: GNU General Public License v2.0 | 6 votes |
private static void updateMenuItemButton(View menuItemButton, MenuItem menuItem, int iconTextSpacing) { ViewGroup viewGroup = (ViewGroup) menuItemButton; final TextView buttonText = (TextView) viewGroup.getChildAt(0); buttonText.setEllipsize(null); if (TextUtils.isEmpty(menuItem.getTitle())) { buttonText.setVisibility(View.GONE); } else { buttonText.setVisibility(View.VISIBLE); buttonText.setText(menuItem.getTitle()); } buttonText.setPaddingRelative(0, 0, 0, 0); /*final CharSequence contentDescription = menuItem.getContentDescription(); TODO if (TextUtils.isEmpty(contentDescription)) { menuItemButton.setContentDescription(menuItem.getTitle()); } else { menuItemButton.setContentDescription(contentDescription); }*/ }
Example 5
Source Project: MissZzzReader Source File: BookcaseDragAdapter.java License: Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(mContext).inflate(mResourceId, null); viewHolder.ivBookImg = convertView.findViewById(R.id.iv_book_img); viewHolder.tvBookName = convertView.findViewById(R.id.tv_book_name); viewHolder.tvNoReadNum = convertView.findViewById(R.id.tv_no_read_num); viewHolder.ivDelete = convertView.findViewById(R.id.iv_delete); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } initView(position, viewHolder); return convertView; }
Example 6
Source Project: Camera-Roll-Android-App Source File: ThemeableActivity.java License: Apache License 2.0 | 6 votes |
private static ArrayList<View> findViewsWithTag(String TAG, ViewGroup rootView, ArrayList<View> views) { Object tag = rootView.getTag(); if (tag != null && tag.equals(TAG)) { views.add(rootView); } for (int i = 0; i < rootView.getChildCount(); i++) { View v = rootView.getChildAt(i); tag = v.getTag(); if (tag != null && tag.equals(TAG)) { views.add(v); } if (v instanceof ViewGroup) { findViewsWithTag(TAG, (ViewGroup) v, views); } } return views; }
Example 7
Source Project: funcodetuts Source File: PageFragment.java License: Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_page, container, false); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.main_recycler); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext()); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setHasFixedSize(true); List<String> list = new ArrayList<>(); for (int i = 0; i < 10; i++) { list.add("Item " + i); } SimpleRecyclerAdapter adapter = new SimpleRecyclerAdapter(list); recyclerView.setAdapter(adapter); adapter.setOnItemTapListener(mListItemClickListener); return view; }
Example 8
Source Project: AndroidChromium Source File: AutofillLocalCardEditor.java License: Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = super.onCreateView(inflater, container, savedInstanceState); mNameLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_name_label); mNameText = (EditText) v.findViewById(R.id.credit_card_name_edit); mNumberLabel = (CompatibilityTextInputLayout) v.findViewById(R.id.credit_card_number_label); mNumberText = (EditText) v.findViewById(R.id.credit_card_number_edit); // Set text watcher to format credit card number mNumberText.addTextChangedListener(new CreditCardNumberFormattingTextWatcher()); mExpirationMonth = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_month_spinner); mExpirationYear = (Spinner) v.findViewById(R.id.autofill_credit_card_editor_year_spinner); addSpinnerAdapters(); addCardDataToEditFields(); initializeButtons(v); return v; }
Example 9
Source Project: Ruisi Source File: ForumsAdapter.java License: Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { CircleImageView imageView; // 声明ImageView的对象 if (convertView == null) { imageView = new CircleImageView(context); AbsListView.LayoutParams p = new AbsListView.LayoutParams(itemWidth, itemWidth); imageView.setLayoutParams(p); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { imageView = (CircleImageView) convertView; } Picasso.get() .load(ds.get(position).imgSrc) .placeholder(R.drawable.image_placeholder) .into(imageView); return imageView; }
Example 10
Source Project: io2015-codelabs Source File: RecipeActivity.java License: Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false); this.recipe = ((RecipeActivity)getActivity()).recipe; TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable); for (Recipe.Ingredient ingredient : recipe.getIngredients()) { TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null); ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount()); ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription()); table.addView(row); } return rootView; }
Example 11
Source Project: ByWebView Source File: StatusBarUtil.java License: Apache License 2.0 | 6 votes |
/** * 设置状态栏颜色 * * @param activity 需要设置的activity * @param color 状态栏颜色值 * @param statusBarAlpha 状态栏透明度 */ public static void setColor(Activity activity, @ColorInt int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha); decorView.addView(statusView); } setRootView(activity); } }
Example 12
Source Project: smart-farmer-android Source File: ViewUtil.java License: Apache License 2.0 | 6 votes |
public static void resetSize(View view, int width, int height){ if (view == null) { return; } ViewGroup.LayoutParams params = view.getLayoutParams(); if (params == null){ params = new ViewGroup.LayoutParams(width, height); view.setLayoutParams(params); return; } boolean hasChanged = false; if (params.width != width){ params.width = width; hasChanged = true; } if (params.height != height){ params.height = height; hasChanged = true; } if (hasChanged) { view.requestLayout(); } }
Example 13
Source Project: LoveTalkClient Source File: BlogDateAdapter.java License: Apache License 2.0 | 6 votes |
TextView getTextView() { //设置TextView的样式 AbsListView.LayoutParams lp = new AbsListView.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, 64); TextView textView = new TextView( mContext); textView.setLayoutParams(lp); textView.setGravity(Gravity.CENTER_VERTICAL); //设置TextView的Padding值 textView.setPadding(16, -10, 0, 32); //设置TextView的字体大小 textView.setTextSize(14); //设置TextView的字体颜色 textView.setTextColor(Color.WHITE); //设置字体加粗 TextPaint txt = textView.getPaint(); txt.setFakeBoldText(true); return textView; }
Example 14
Source Project: codeexamples-android Source File: MySimplePerformanceArrayAdapter.java License: Eclipse Public License 1.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; if (rowView == null) { LayoutInflater inflater = context.getLayoutInflater(); rowView = inflater.inflate(R.layout.rowlayout, null); } TextView textView = (TextView) rowView.findViewById(R.id.label); ImageView imageView = (ImageView) rowView.findViewById(R.id.icon); String s = names[position]; textView.setText(s); if (s.startsWith("Windows7") || s.startsWith("iPhone") || s.startsWith("Solaris")) { imageView.setImageResource(R.drawable.no); } else { imageView.setImageResource(R.drawable.ok); } return rowView; }
Example 15
Source Project: privacy-friendly-pedometer Source File: ReportAdapter.java License: GNU General Public License v3.0 | 6 votes |
@Override public ReportAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v; ViewHolder vh; switch (viewType) { case TYPE_CHART: v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_activity_bar_chart, parent, false); vh = new CombinedChartViewHolder(v); break; case TYPE_DAY_CHART: v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_activity_chart, parent, false); vh = new ChartViewHolder(v); break; case TYPE_SUMMARY: default: v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_activity_summary, parent, false); vh = new SummaryViewHolder(v); break; } return vh; }
Example 16
Source Project: MousePaint Source File: Delegate.java License: MIT License | 6 votes |
/** * 显示模糊背景 */ protected void showShowdown() { ViewHelper.setTranslationY(mRootView, 0); mEffect.effect(mParentVG,mBg); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); if(mBg.getParent()!= null){ mParentVG.removeView(mBg); } mParentVG.addView(mBg, lp); ViewHelper.setAlpha(mBg, 0); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 0, 1); objectAnimator.setDuration(400); objectAnimator.start(); }
Example 17
Source Project: osmdroid Source File: ExpandableListAdapter.java License: Apache License 2.0 | 6 votes |
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_group, null); } TextView lblListHeader = convertView .findViewById(R.id.lblListHeader); lblListHeader.setTypeface(null, Typeface.BOLD); lblListHeader.setText(headerTitle); return convertView; }
Example 18
Source Project: Muzesto Source File: AlbumFragment.java License: GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate( R.layout.fragment_recyclerview, container, false); recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview); fastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.hide(); ImageView backdrop = (ImageView) rootView.findViewById(R.id.white_backdrop); backdrop.setVisibility(View.VISIBLE); setLayoutManager(); if (getActivity() != null) new loadAlbums().execute(""); return rootView; }
Example 19
Source Project: ProjectX Source File: ViewsPagerAdapter.java License: Apache License 2.0 | 5 votes |
@NonNull @Override public Object instantiateItem(@NonNull ViewGroup container, int position) { final ViewHolder holder = mItems.get(position); holder.mPosition = position; holder.mNeedRebind = false; holder.mPositionChanged = false; holder.mRemoved = false; final View view = holder.itemView; onBindView(view, position); container.addView(view); mItemsInLayout.add(holder); return holder; }
Example 20
Source Project: material-components-android Source File: ScaleProvider.java License: Apache License 2.0 | 5 votes |
@Nullable @Override public Animator createDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view) { if (!scaleOnDisappear) { return null; } if (growing) { return createScaleAnimator(view, outgoingStartScale, outgoingEndScale); } else { return createScaleAnimator(view, incomingEndScale, incomingStartScale); } }
Example 21
Source Project: mlkit-material-android Source File: EntryChoiceActivity.java License: Apache License 2.0 | 5 votes |
@NonNull @Override public EntryItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new EntryItemViewHolder( LayoutInflater.from(parent.getContext()) .inflate(R.layout.entry_item, parent, false)); }
Example 22
Source Project: imsdk-android Source File: RNMineFragment.java License: MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); return mReactRootView; }
Example 23
Source Project: ShareBox Source File: VerticalStepperView.java License: Apache License 2.0 | 5 votes |
private void prepareListView(Context context) { mListView = new RecyclerView(context); mAdapter = new ItemAdapter(); mListView.setClipToPadding(false); mListView.setPadding(0, getResources().getDimensionPixelSize(R.dimen.stepper_margin_top), 0, 0); mListView.addItemDecoration(new VerticalSpaceItemDecoration( getResources().getDimensionPixelSize(R.dimen.vertical_stepper_item_space_height))); mListView.setLayoutManager(new LinearLayoutManager(context)); mListView.setAdapter(mAdapter); addView(mListView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
Example 24
Source Project: Walk-In-Clinic-Android-App Source File: UserList.java License: MIT License | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View listViewItem = inflater.inflate(R.layout.layout_user_list, null, true); TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName); TextView textViewRole = (TextView) listViewItem.findViewById(R.id.textViewRole); TextView textViewUsername = (TextView) listViewItem.findViewById(R.id.textViewUsername); DataBaseUser user = users.get(position); textViewName.setText("Name: " + user.getName()); textViewRole.setText("Role: " + String.valueOf(user.getRole())); textViewUsername.setText("Username: " + String.valueOf(user.getUsername())); return listViewItem; }
Example 25
Source Project: timecat Source File: PlansFragment.java License: Apache License 2.0 | 5 votes |
@Override protected View initViews(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_routines, container, false); progressBar = view.findViewById(R.id.progress_bar); frameLayout = view.findViewById(R.id.fragment_container); mRefreshLayout = view.findViewById(R.id.refreshLayout); initView(); return view; }
Example 26
Source Project: Android-Applications-Info Source File: DetailFragment.java License: Apache License 2.0 | 5 votes |
/** * Boring view inflation / creation */ private View getServicesView(ViewGroup viewGroup, View convertView, int index) { ViewHolder viewHolder; if (!checkIfConvertViewMatch(convertView, SERVICES)) { convertView = mLayoutInflater.inflate(R.layout.detail_activities, viewGroup, false); viewHolder = new ViewHolder(); viewHolder.currentViewType = SERVICES; viewHolder.imageView = (ImageView) convertView.findViewById(R.id.icon); viewHolder.textView1 = (TextView) convertView.findViewById(R.id.label); viewHolder.textView2 = (TextView) convertView.findViewById(R.id.name); viewHolder.textView3 = (TextView) convertView.findViewById(R.id.launchMode); convertView.findViewById(R.id.taskAffinity).setVisibility(View.GONE); convertView.findViewById(R.id.orientation).setVisibility(View.GONE); convertView.findViewById(R.id.softInput).setVisibility(View.GONE); convertView.findViewById(R.id.launch).setVisibility(View.GONE); } else { viewHolder = (ViewHolder) convertView.getTag(); } final ServiceInfo serviceInfo = mPackageInfo.services[index]; convertView.setBackgroundColor(index % 2 == 0 ? mColorGrey1 : mColorGrey2); //Label viewHolder.textView1.setText(serviceInfo.loadLabel(mPackageManager)); //Name viewHolder.textView2.setText(serviceInfo.name.replaceFirst(mPackageName, "")); //Icon viewHolder.imageView.setImageDrawable(serviceInfo.loadIcon(mPackageManager)); //Flags viewHolder.textView3.setText(getString(R.string.flags) + ": " + Utils.getServiceFlagsString(serviceInfo.flags)); return convertView; }
Example 27
Source Project: ShrinkingImageLayout Source File: ShrinkingImageLayout.java License: Apache License 2.0 | 5 votes |
public void setImageMaximumHeight(int maximumHeight) { imageMaximumHeight = maximumHeight; View space = header.findViewById(R.id.space); ViewGroup.LayoutParams spaceParams = space.getLayoutParams(); spaceParams.height = maximumHeight; space.setLayoutParams(spaceParams); ViewGroup.LayoutParams parallaxParams = parallaxScrimageView.getLayoutParams(); parallaxParams.height = maximumHeight; parallaxScrimageView.setLayoutParams(parallaxParams); }
Example 28
Source Project: Fatigue-Detection Source File: EffectAdapter.java License: MIT License | 5 votes |
@Override public EffectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.effect_item_layout, parent, false); EffectHolder viewHolder = new EffectHolder(view); viewHolder.thumbImage = (ImageView) view .findViewById(R.id.effect_thumb_image); viewHolder.filterRoot = (LinearLayout) view .findViewById(R.id.effect_root); viewHolder.filterImg = (FrameLayout) view.findViewById(R.id.effect_img_panel); return viewHolder; }
Example 29
Source Project: openvidonn Source File: BluetoothDevicesFragment.java License: GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView()"); View view = inflater.inflate(R.layout.fragment_bluetoothdevices, container, false); // Set the adapter mListView = (AbsListView) view.findViewById(android.R.id.list); ((AdapterView<ListAdapter>) mListView).setAdapter(devicesList); return view; }
Example 30
Source Project: AndroidUiKit Source File: MultiTypeLoadMoreAdapter.java License: Apache License 2.0 | 5 votes |
@NonNull @Override protected final VH onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { VH viewHolder = createViewHolder(inflater, parent); viewHolder.mListener = mListener; return viewHolder; }