Java Code Examples for android.widget.FrameLayout
The following examples show how to use
android.widget.FrameLayout. 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: hintcase Source File: SimpleHintContentHolder.java License: Apache License 2.0 | 6 votes |
@Override public View getView(Context context, final HintCase hintCase, ViewGroup parent) { FrameLayout.LayoutParams frameLayoutParamsBlock = getParentLayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, gravity, marginLeft, marginTop, marginRight, marginBottom); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setLayoutParams(frameLayoutParamsBlock); linearLayout.setGravity(Gravity.CENTER); linearLayout.setOrientation(LinearLayout.VERTICAL); if (contentTitle != null) { linearLayout.addView(getTextViewTitle(context)); } if (existImage()) { linearLayout.addView(getImage(context, imageView, imageResourceId)); } if (contentText != null) { linearLayout.addView(getTextViewDescription(context)); } return linearLayout; }
Example 2
Source Project: Augendiagnose Source File: AutoKeyboardLayoutUtility.java License: GNU General Public License v2.0 | 6 votes |
/** * Constructor, adding a listener to change the global layout if required. * * @param activity the activity which uses the workaround. */ private AutoKeyboardLayoutUtility(@NonNull final Activity activity) { FrameLayout content = activity.findViewById(android.R.id.content); mChildOfContent = content.getChildAt(0); mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { possiblyResizeChildOfContent(); } }); mFrameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); if (activity instanceof ActivityWithExplicitLayoutTrigger) { mActivityWithLayoutTrigger = (ActivityWithExplicitLayoutTrigger) activity; } }
Example 3
Source Project: Expandable-Action-Button Source File: ExpandableButtonView.java License: MIT License | 6 votes |
private void init(Context context){ actionButton=new FloatingActionButton(context); toolbarLayout=new LinearLayout(getContext()); float density = getResources().getDisplayMetrics().density; addView(actionButton,(int)(56*density),(int)(56*density)); FrameLayout.LayoutParams params= FrameLayout.LayoutParams.class.cast(actionButton.getLayoutParams()); params.gravity= Gravity.CENTER; actionButton.setLayoutParams(params); toolbarLayout.setGravity(Gravity.CENTER); actionButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onButtonClick(); } }); fabDrawable=actionButton.getDrawable(); if(fabDrawable!=null) actionButton.setImageDrawable(fabDrawable); setToolbarColor(-1); }
Example 4
Source Project: TextOcrExample Source File: MainActivity.java License: Apache License 2.0 | 6 votes |
@Override public void onConfigurationChanged(Configuration newConfig) { FrameLayout.LayoutParams imgParams = (FrameLayout.LayoutParams) mCapturePhoto.getLayoutParams(); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { // 横屏 mScreenOrientation = Configuration.ORIENTATION_LANDSCAPE; imgParams.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT; } else { // 竖屏 mScreenOrientation = Configuration.ORIENTATION_PORTRAIT; imgParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; } mCapturePhoto.setLayoutParams(imgParams); if (mCamera != null) startPreview(mCamera, mSvHolder); super.onConfigurationChanged(newConfig); }
Example 5
Source Project: ucar-weex-core Source File: WXScroller.java License: Apache License 2.0 | 6 votes |
@Override protected MeasureOutput measure(int width, int height) { MeasureOutput measureOutput = new MeasureOutput(); if (this.mOrientation == Constants.Orientation.HORIZONTAL) { int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication); int weexW = WXViewUtils.getWeexWidth(getInstanceId()); measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT : width; measureOutput.height = height; } else { int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication); int weexH = WXViewUtils.getWeexHeight(getInstanceId()); measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT : height; measureOutput.width = width; } return measureOutput; }
Example 6
Source Project: actor-platform Source File: FastAttachAdapter.java License: GNU Affero General Public License v3.0 | 6 votes |
public FastShareVH(View itemView) { super(itemView); itemView.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor()); v = (SimpleDraweeView) itemView.findViewById(R.id.image); chb = (CheckBox) itemView.findViewById(R.id.check); int size = Screen.dp(80); v.setLayoutParams(new FrameLayout.LayoutParams(size, size)); chb.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked && data != null) { selected.add(data); notifyVm(); } else { selected.remove(data); notifyVm(); } }); }
Example 7
Source Project: android_tv_metro Source File: MainActivity.java License: Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); mTabs = (TabWidget)findViewById(android.R.id.tabs); ViewStub vStub = (ViewStub) findViewById(R.id.new_home_menu); mMenuContainer = (FrameLayout) vStub.inflate(); mViewPager = (ViewPager)findViewById(R.id.pager); mLoadingView = makeEmptyLoadingView(this, (RelativeLayout)findViewById(R.id.tabs_content)); setScrollerTime(800); albumItem = (DisplayItem) getIntent().getSerializableExtra("item"); setUserFragmentClass(); getSupportLoaderManager().initLoader(TabsGsonLoader.LOADER_ID, null, this); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } }
Example 8
Source Project: Bitocle Source File: FloatingActionButton.java License: Apache License 2.0 | 6 votes |
/** * Constructor that takes parameters collected using {@link FloatingActionMenu.Builder} * @param activity a reference to the activity that will * @param layoutParams * @param theme * @param backgroundDrawable * @param position * @param contentView * @param contentParams */ public FloatingActionButton(Activity activity, LayoutParams layoutParams, int theme, Drawable backgroundDrawable, int position, View contentView, FrameLayout.LayoutParams contentParams) { super(activity); setPosition(position, layoutParams); // If no custom backgroundDrawable is specified, use the background drawable of the theme. if(backgroundDrawable == null) { if(theme == THEME_LIGHT) backgroundDrawable = activity.getResources().getDrawable(R.drawable.button_action_selector); else backgroundDrawable = activity.getResources().getDrawable(R.drawable.button_action_dark_selector); } setBackgroundResource(backgroundDrawable); if(contentView != null) { setContentView(contentView, contentParams); } setClickable(true); attach(layoutParams); }
Example 9
Source Project: squidb Source File: SquidRecyclerAdapterTest.java License: Apache License 2.0 | 6 votes |
public void testViewHolderItemBinding() { final TestModel model1 = database.fetch(TestModel.class, 1, TestModel.PROPERTIES); final TestModel model2 = database.fetch(TestModel.class, 2, TestModel.PROPERTIES); testRecyclerAdapterInternal(TestModel.ID, new RecyclerAdapterTest() { @Override public void testRecyclerAdapter(TestRecyclerAdapter adapter) { FrameLayout parent = new FrameLayout(ContextProvider.getContext()); TestViewHolder holder = adapter.onCreateViewHolder(parent, adapter.getItemViewType(0)); adapter.onBindViewHolder(holder, 0); assertEquals(model1, holder.item); assertEquals(model1.getDisplayName(), holder.textView.getText().toString()); adapter.onBindViewHolder(holder, 1); assertEquals(model2, holder.item); assertEquals(model2.getDisplayName(), holder.textView.getText().toString()); } }); }
Example 10
Source Project: a Source File: NumberPickerPreference.java License: GNU General Public License v3.0 | 6 votes |
/** * @return dialog view with picker inside */ @Override protected View onCreateDialogView() { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; numPicker = new NumberPicker(getContext()); numPicker.setLayoutParams(layoutParams); numPicker.setMinValue(minValue); numPicker.setMaxValue(maxValue); FrameLayout dialogView = new FrameLayout(getContext()); dialogView.addView(numPicker); return dialogView; }
Example 11
Source Project: coursera-android Source File: ToggleButtonActivity.java License: MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get references to a background containers final FrameLayout top = findViewById(R.id.top_frame); final FrameLayout bottom = findViewById(R.id.bottom_frame); // Get a reference to the ToggleButton final ToggleButton toggleButton = findViewById(R.id.togglebutton); // Set an setOnCheckedChangeListener on the ToggleButton setListener(toggleButton, top); // Get a reference to the Switch final Switch switcher = findViewById(R.id.switcher); // Set an OnCheckedChangeListener on the Switch setListener(switcher, bottom); }
Example 12
Source Project: BubbleAlert Source File: BblDialogFragmentBase.java License: MIT License | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); View contentView = onCreateView(getActivity().getLayoutInflater()); if (contentView == null) { dismiss(); return; } LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1)); linearLayout.setLayoutParams(containerLayoutParams); contentView.setLayoutParams(new LinearLayout.LayoutParams(-1, 0, 1)); linearLayout.addView(contentView); container.addView(linearLayout); }
Example 13
Source Project: DoraemonKit Source File: UIPerformanceInfoDokitView.java License: Apache License 2.0 | 6 votes |
@Override public void onViewCreated(FrameLayout view) { mClose = findViewById(R.id.close); mClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DokitViewManager.getInstance().detach(UIPerformanceDisplayDokitView.class.getSimpleName()); DokitViewManager.getInstance().detach(UIPerformanceInfoDokitView.class.getSimpleName()); UIPerformanceManager.getInstance().stop(); } }); mMaxLevelText = findViewById(R.id.max_level); mMaxLevelViewIdText = findViewById(R.id.max_level_view_id); mTotalTimeText = findViewById(R.id.total_time); mMaxTimeText = findViewById(R.id.max_time); mMaxTimeViewIdText = findViewById(R.id.max_time_view_id); }
Example 14
Source Project: nearby-android Source File: MapActivity.java License: Apache License 2.0 | 6 votes |
/** * Restore map to original size and remove * views associated with displaying route segments. * @return MapFragment - The fragment containing the map */ public final MapFragment restoreMapAndRemoveRouteDetail(){ // Remove the route directions final LinearLayout layout = findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0)); layout.requestLayout(); // Show the map final FrameLayout mapLayout = findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); final FragmentManager fm = getSupportFragmentManager(); final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container); mapFragment.removeRouteDetail(); return mapFragment; }
Example 15
Source Project: SlideLayout Source File: SlideLayout.java License: GNU General Public License v2.0 | 6 votes |
protected void setLeftMenuView(int viewWidth, int viewHeight){ View menu = getLeftMenuView(); if(menu == null) return; if(mLeftMenuStyle.mMenuBorderPercent >= 0f) mLeftMenuStyle.mMenuBorder = (int)(viewWidth * mLeftMenuStyle.mMenuBorderPercent); if(mLeftMenuStyle.mMenuOverDragBorderPercent >= 0f) mLeftMenuStyle.mMenuOverDragBorder = (int)(viewWidth * mLeftMenuStyle.mMenuOverDragBorderPercent); mLeftMenuStyle.mSize = viewWidth - mLeftMenuStyle.mMenuBorder; if(mLeftMenuStyle.mCloseEdgePercent >= 0f) mLeftMenuStyle.mCloseEdge = (int)(mLeftMenuStyle.mSize * mLeftMenuStyle.mCloseEdgePercent); menu.setLayoutParams(new FrameLayout.LayoutParams(mLeftMenuStyle.mSize, FrameLayout.LayoutParams.MATCH_PARENT)); menu.setVisibility(mOffsetX <= 0 ? View.GONE : View.VISIBLE); }
Example 16
Source Project: prebid-mobile-android Source File: ExtraTests.java License: Apache License 2.0 | 5 votes |
@Test public void testAppNexusInvalidPrebidServerConfigId() throws Exception { PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext()); PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0"); PrebidMobile.setPrebidServerHost(Host.APPNEXUS); PrebidMobile.setShareGeoLocation(true); final OnCompleteListener[] listener = new OnCompleteListener[1]; mHandler.post(new Runnable() { @Override public void run() { final MoPubView adObject = new MoPubView(m.getActivity()); adObject.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_300x250_APPNEXUS); adObject.setMinimumHeight(250); adObject.setMinimumWidth(300); BannerAdUnit adUnit = new BannerAdUnit("6ace8c7d-88c0-4623-8117-ffffffffffff", 300, 250); OnCompleteListener l = new OnCompleteListener() { @Override public void onComplete(ResultCode resultCode) { FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame); adFrame.addView(adObject); adObject.loadAd(); } }; listener[0] = spy(l); adUnit.fetchDemand(adObject, listener[0]); } }); Thread.sleep(10000); verify(listener[0], times(1)).onComplete(ResultCode.INVALID_CONFIG_ID); }
Example 17
Source Project: likequanmintv Source File: PullToZoomScrollViewEx.java License: Apache License 2.0 | 5 votes |
@Override public void handleStyledAttributes(TypedArray a) { mRootContainer = new LinearLayout(getContext()); mRootContainer.setOrientation(LinearLayout.VERTICAL); mHeaderContainer = new FrameLayout(getContext()); if (mZoomView != null) { mHeaderContainer.addView(mZoomView); } if (mHeaderView != null) { mHeaderContainer.addView(mHeaderView); } int contentViewResId = a.getResourceId(R.styleable.PullToZoomView_contentView, 0); if (contentViewResId > 0) { LayoutInflater mLayoutInflater = LayoutInflater.from(getContext()); mContentView = mLayoutInflater.inflate(contentViewResId, null, false); } mRootContainer.addView(mHeaderContainer); if (mContentView != null) { mRootContainer.addView(mContentView); } mRootContainer.setClipChildren(false); mHeaderContainer.setClipChildren(false); mRootView.addView(mRootContainer); }
Example 18
Source Project: LbaizxfPulltoRefresh Source File: PullToRefreshAdapterViewBase.java License: Apache License 2.0 | 5 votes |
private static FrameLayout.LayoutParams convertEmptyViewLayoutParams(ViewGroup.LayoutParams lp) { FrameLayout.LayoutParams newLp = null; if (null != lp) { newLp = new FrameLayout.LayoutParams(lp); if (lp instanceof LinearLayout.LayoutParams) { newLp.gravity = ((LinearLayout.LayoutParams) lp).gravity; } else { newLp.gravity = Gravity.CENTER; } } return newLp; }
Example 19
Source Project: YCWebView Source File: AndroidBug5497Workaround.java License: Apache License 2.0 | 5 votes |
public AndroidBug5497Workaround(Activity activity) { if (activity!=null){ FrameLayout content = activity.findViewById(android.R.id.content); mChildOfContent = content.getChildAt(0); mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(listener); frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); } }
Example 20
Source Project: Study_Android_Demo Source File: EaseChatInputMenu.java License: Apache License 2.0 | 5 votes |
private void init(Context context, AttributeSet attrs) { this.context = context; layoutInflater = LayoutInflater.from(context); layoutInflater.inflate(R.layout.ease_widget_chat_input_menu, this); primaryMenuContainer = (FrameLayout) findViewById(R.id.primary_menu_container); emojiconMenuContainer = (FrameLayout) findViewById(R.id.emojicon_menu_container); chatExtendMenuContainer = (FrameLayout) findViewById(R.id.extend_menu_container); // extend menu chatExtendMenu = (EaseChatExtendMenu) findViewById(R.id.extend_menu); }
Example 21
Source Project: PowerfulRecyclerView Source File: SimpleHeaderContainer.java License: Apache License 2.0 | 5 votes |
private void initView() { FrameLayout container = (FrameLayout)getChildAt(0); iv = (SimpleImageView)container.getChildAt(0); pb = (ProgressBar)container.getChildAt(1); tv = (SimpleTextView)getChildAt(1); iv.setImageDrawable(getResources().getDrawable(R.drawable.ptr_down_arrow)); }
Example 22
Source Project: nono-android Source File: BaseActivityWithDrawer.java License: GNU General Public License v3.0 | 5 votes |
protected void registerDrawer() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if(iDrawerClosedCallBack != null){ iDrawerClosedCallBack.onDrawerClosed(); } } }; drawer.setDrawerListener(toggle); toggle.syncState(); navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); tintNavView(ThemeController.getCurrentColor().mainColor); headerLayout = (FrameLayout) LayoutInflater.from(this).inflate(R.layout.nav_header_main, null); ImageView imageView=(ImageView)headerLayout.findViewById(R.id.nav_header_back); imageView.setImageDrawable(ImageProcessor.zoomImageMin( ContextCompat.getDrawable(this, R.drawable.navigation_header) , getResources().getDisplayMetrics().widthPixels , getResources().getDisplayMetrics().widthPixels)); navigationView.addHeaderView(headerLayout); }
Example 23
Source Project: zen4android Source File: PullToRefreshBase.java License: MIT License | 5 votes |
private void addRefreshableView(Context context, T refreshableView) { mRefreshableViewWrapper = new FrameLayout(context); mRefreshableViewWrapper.addView(refreshableView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); addViewInternal(mRefreshableViewWrapper, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); }
Example 24
Source Project: BottomBar Source File: BottomBarTabTest.java License: Apache License 2.0 | 5 votes |
@Before public void setUp() { tabContainer = new FrameLayout(InstrumentationRegistry.getContext()); tab = new BottomBarTab(InstrumentationRegistry.getContext()); tabContainer.addView(tab); }
Example 25
Source Project: Android-ObservableScrollView Source File: TouchInterceptionRecyclerViewActivity.java License: Apache License 2.0 | 5 votes |
private void slideTo(float translationY, final boolean animated) { ViewHelper.setTranslationY(mInterceptionLayout, translationY); if (translationY < 0) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams(); lp.height = (int) -translationY + getScreenHeight(); mInterceptionLayout.requestLayout(); } }
Example 26
Source Project: GravityBox Source File: NotificationWallpaper.java License: Apache License 2.0 | 5 votes |
public NotificationWallpaper(FrameLayout container, XSharedPreferences prefs) throws Throwable { mNotificationPanelView = container; mContext = mNotificationPanelView.getContext(); mBackupBg = mNotificationPanelView.getBackground(); Context gbContext = Utils.getGbContext(mContext); mNotifBgImagePathPortrait = gbContext.getFilesDir() + "/notifwallpaper"; mNotifBgImagePathLandscape = gbContext.getFilesDir() + "/notifwallpaper_landscape"; initPreferences(prefs); createHooks(); prepareWallpaper(); }
Example 27
Source Project: android-open-project-demo Source File: ExpandableListItemAdapter.java License: Apache License 2.0 | 5 votes |
private void init() { setOrientation(VERTICAL); mTitleViewGroup = new FrameLayout(getContext()); mTitleViewGroup.setId(DEFAULTTITLEPARENTRESID); addView(mTitleViewGroup); mContentViewGroup = new FrameLayout(getContext()); mContentViewGroup.setId(DEFAULTCONTENTPARENTRESID); addView(mContentViewGroup); }
Example 28
Source Project: material-components-android Source File: BadgeUtils.java License: Apache License 2.0 | 5 votes |
public static void attachBadgeDrawable( @NonNull BadgeDrawable badgeDrawable, @NonNull View anchor, @Nullable FrameLayout compatBadgeParent) { setBadgeDrawableBounds(badgeDrawable, anchor, compatBadgeParent); if (USE_COMPAT_PARENT) { if (compatBadgeParent == null) { throw new IllegalArgumentException("Trying to reference null compatBadgeParent"); } compatBadgeParent.setForeground(badgeDrawable); } else { anchor.getOverlay().add(badgeDrawable); } }
Example 29
Source Project: Ecommerce-Morningmist-Android Source File: MainActivity.java License: Creative Commons Zero v1.0 Universal | 5 votes |
@Override public void initUIHandles() { // TODO Auto-generated method stub llHead = (LinearLayout)findViewById(R.id.ll_head); ivHeadTitle = (ImageView)findViewById(R.id.iv_head_title); ivHeadCart = (ImageView)findViewById(R.id.iv_head_cart); ivHeadMenu = (ImageView)findViewById(R.id.iv_head_menu); tvCartNotif = (TextView)findViewById(R.id.tv_cart_notif); flBody = (FrameLayout)findViewById(R.id.ll_body); tf = Typeface.createFromAsset(getAssets(), "icomoon.ttf"); }
Example 30
Source Project: commcare-android Source File: FormLayoutHelpers.java License: Apache License 2.0 | 5 votes |
public static void updateGroupViewVisibility(FormEntryActivity activity, boolean hasGroupLabel, boolean shouldHideGroupLabel) { FrameLayout header = activity.findViewById(R.id.form_entry_header); TextView groupLabel = header.findViewById(R.id.form_entry_group_label); updateGroupViewVisibility(header, groupLabel, hasGroupLabel, shouldHideGroupLabel); }