android.widget.FrameLayout Java Examples
The following examples show how to use
android.widget.FrameLayout.
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 File: SlideLayout.java From SlideLayout with 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 #2
Source File: ExpandableButtonView.java From Expandable-Action-Button with 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 #3
Source File: AutoKeyboardLayoutUtility.java From Augendiagnose with 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 #4
Source File: NumberPickerPreference.java From a with 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 #5
Source File: MainActivity.java From TextOcrExample with 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 #6
Source File: WXScroller.java From ucar-weex-core with 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 #7
Source File: FastAttachAdapter.java From actor-platform with 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 #8
Source File: MainActivity.java From android_tv_metro with 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 #9
Source File: FloatingActionButton.java From Bitocle with 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 #10
Source File: SquidRecyclerAdapterTest.java From squidb with 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 #11
Source File: SimpleHintContentHolder.java From hintcase with 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 #12
Source File: ToggleButtonActivity.java From coursera-android with 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 #13
Source File: BblDialogFragmentBase.java From BubbleAlert with 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 #14
Source File: UIPerformanceInfoDokitView.java From DoraemonKit with 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 #15
Source File: MapActivity.java From nearby-android with 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 #16
Source File: PhotoCropActivity.java From KrGallery with GNU General Public License v2.0 | 5 votes |
@Override public View createView(Context context) { actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR); actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR); // actionBar.setTitleColor(0xffffffff); actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle("裁剪"); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (delegate != null && !doneButtonPressed) { Bitmap bitmap = view.getBitmap(); if (bitmap == imageToCrop) { sameBitmap = true; } delegate.didFinishEdit(bitmap); doneButtonPressed = true; } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); fragmentView = view = new PhotoCropView(context); ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false); fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); return fragmentView; }
Example #17
Source File: ItemStyleActivity.java From TimetableView with MIT License | 5 votes |
/** * 设置角度(四个角分别控制) * * @param leftTop * @param rightTop * @param rightBottom * @param leftBottom */ public void setCorner(final int leftTop, final int rightTop, final int rightBottom, final int leftBottom) { mTimetableView.callback(new OnItemBuildAdapter() { @Override public void onItemUpdate(FrameLayout layout, TextView textView, TextView countTextView, Schedule schedule, GradientDrawable gd) { super.onItemUpdate(layout, textView, countTextView, schedule, gd); //数组8个元素,四个方向依次为左上、右上、右下、左下, // 每个方向在数组中占两个元素,值相同 gd.setCornerRadii(new float[]{leftTop, leftTop, rightTop, rightTop, rightBottom, rightBottom, leftBottom, leftBottom}); } }); mTimetableView.updateView(); }
Example #18
Source File: SlideInAnimationHandler.java From android-open-project-demo with Apache License 2.0 | 5 votes |
@Override public void animateMenuOpening(Point center) { super.animateMenuOpening(center); setAnimating(true); Animator lastAnimation = null; for (int i = 0; i < menu.getSubActionItems().size(); i++) { menu.getSubActionItems().get(i).view.setAlpha(0); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) menu.getSubActionItems().get(i).view.getLayoutParams(); params.setMargins(menu.getSubActionItems().get(i).x, menu.getSubActionItems().get(i).y + DIST_Y, 0, 0); menu.getSubActionItems().get(i).view.setLayoutParams(params); // PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, menu.getSubActionItems().get(i).x/* - center.x + menu.getSubActionItems().get(i).width / 2*/); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -DIST_Y); // PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); // PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1); final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA); animation.setDuration(DURATION); animation.setInterpolator(new DecelerateInterpolator()); animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING)); if(i == 0) { lastAnimation = animation; } animation.setStartDelay(Math.abs(menu.getSubActionItems().size()/2-i) * LAG_BETWEEN_ITEMS); animation.start(); } if(lastAnimation != null) { lastAnimation.addListener(new LastAnimationListener()); } }
Example #19
Source File: QuestionWidget.java From commcare-android with Apache License 2.0 | 5 votes |
private void addHelpPlaceholder() { if (!mPrompt.hasHelp()) { return; } helpPlaceholder = new FrameLayout(this.getContext()); helpPlaceholder.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); final ImageButton trigger = new ImageButton(getContext()); trigger.setScaleType(ScaleType.FIT_CENTER); trigger.setImageResource(R.drawable.icon_info_outline_lightcool); trigger.setBackgroundDrawable(null); trigger.setOnClickListener(v -> { trigger.setImageResource(R.drawable.icon_info_fill_lightcool); fireHelpText(() -> { // back to the old icon trigger.setImageResource(R.drawable.icon_info_outline_lightcool); }); }); trigger.setId(847294011); LinearLayout triggerLayout = new LinearLayout(getContext()); triggerLayout.setOrientation(LinearLayout.HORIZONTAL); triggerLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); triggerLayout.setGravity(Gravity.RIGHT); triggerLayout.addView(trigger); MediaLayout helpLayout = createHelpLayout(); helpLayout.setBackgroundResource(R.color.very_light_blue); helpPlaceholder.addView(helpLayout); this.addView(triggerLayout); this.addView(helpPlaceholder); helpPlaceholder.setVisibility(View.GONE); }
Example #20
Source File: EditorActivity.java From PHONK with GNU General Public License v3.0 | 5 votes |
/** * Show / hide file manager */ public void showFileManagerDrawer(boolean show) { FrameLayout fileManager = findViewById(R.id.fragmentFileManager); if (show) { fileManager.setVisibility(View.VISIBLE); } else { fileManager.setVisibility(View.GONE); } }
Example #21
Source File: BarChartFrag.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_simple_bar, container, false); // create a new chart object mChart = new BarChart(getActivity()); mChart.setDescription(""); mChart.setOnChartGestureListener(this); MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view); mChart.setMarkerView(mv); mChart.setDrawGridBackground(false); mChart.setDrawBarShadow(false); Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); mChart.setData(generateBarData(1, 20000, 12)); Legend l = mChart.getLegend(); l.setTypeface(tf); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.setTypeface(tf); leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true) mChart.getAxisRight().setEnabled(false); XAxis xAxis = mChart.getXAxis(); xAxis.setEnabled(false); // programatically add the chart FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout); parent.addView(mChart); return v; }
Example #22
Source File: DismissingUtils.java From keyboard-dismisser with Apache License 2.0 | 5 votes |
private static View getContentView(Activity activity) { if (activity == null) { return null; } FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content); View contentView = content.getChildAt(0); return (contentView != null) ? contentView : content; }
Example #23
Source File: MapwizeFragment.java From mapwize-ui-android with MIT License | 5 votes |
@Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mapwizeUIView = new MapwizeUIView(view.getContext(), initializeOptions, initializeUiSettings, mapwizeConfiguration); mapwizeUIView.setListener((MapwizeUIView.OnViewInteractionListener) view.getContext()); FrameLayout layout = view.findViewById(R.id.mapViewContainer); layout.addView(mapwizeUIView); mapwizeUIView.onCreate(savedInstanceState); }
Example #24
Source File: BaseActivityWithDrawer.java From nono-android with 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 #25
Source File: PullToZoomScrollViewEx.java From likequanmintv with 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 #26
Source File: ViewRouterTest.java From android-router with MIT License | 5 votes |
@Test public void testTrailingUris() { FrameLayout root = new FrameLayout(getContext()); ViewRouter r = new ViewRouter(root) .add("/foo/...", BarView.class) .add("/...", BazView.class); r.route("/foo/hello/world"); assertEquals(BarView.class, root.getChildAt(0).getClass()); assertEquals("/hello/world", ((BarView) root.getChildAt(0)).uriRemainder); r.route("/hello/world"); assertEquals(BazView.class, root.getChildAt(0).getClass()); assertEquals("/hello/world", ((BazView) root.getChildAt(0)).uriRemainder); }
Example #27
Source File: LayoutUtils.java From Android-SDK-Demo with MIT License | 5 votes |
public static FrameLayout.LayoutParams createFrameParams(final int width, final int height, final int layoutGravity, final Margins margins) { final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( width, height ); params.gravity = layoutGravity; params.setMargins( margins.getLeft(), margins.getTop(), margins.getRight(), margins.getBottom() ); return params; }
Example #28
Source File: PullToRefreshBase.java From SwipeMenuAndRefresh with Apache License 2.0 | 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 #29
Source File: PullToRefreshAdapterViewBase.java From PullToRefreshLibrary with Apache License 2.0 | 5 votes |
/** * Sets the Empty View to be used by the Adapter View. * <p/> * We need it handle it ourselves so that we can Pull-to-Refresh when the * Empty View is shown. * <p/> * Please note, you do <strong>not</strong> usually need to call this method * yourself. Calling setEmptyView on the AdapterView will automatically call * this method and set everything up. This includes when the Android * Framework automatically sets the Empty View based on it's ID. * * @param newEmptyView - Empty View to be used */ public final void setEmptyView(View newEmptyView) { FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); if (null != newEmptyView) { // New view needs to be clickable so that Android recognizes it as a // target for Touch Events newEmptyView.setClickable(true); ViewParent newEmptyViewParent = newEmptyView.getParent(); if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) { ((ViewGroup) newEmptyViewParent).removeView(newEmptyView); } // We need to convert any LayoutParams so that it works in our // FrameLayout FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams()); if (null != lp) { refreshableViewWrapper.addView(newEmptyView, lp); } else { refreshableViewWrapper.addView(newEmptyView); } } if (mRefreshableView instanceof EmptyViewMethodAccessor) { ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView); } else { mRefreshableView.setEmptyView(newEmptyView); } mEmptyView = newEmptyView; }
Example #30
Source File: PullToRefreshAdapterViewBase.java From LbaizxfPulltoRefresh with 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; }