Java Code Examples for android.widget.FrameLayout.LayoutParams#setMargins()

The following examples show how to use android.widget.FrameLayout.LayoutParams#setMargins() . 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: PhoneTabRecyclerAdapter.java    From ChromeLikeTabSwitcher with Apache License 2.0 6 votes vote down vote up
/**
 * Inflates the view, which is associated with a tab, and adds it to the view hierarchy.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, whose associated view should be inflated,
 *         as an instance of the class {@link TabItem}. The tab item may not be null
 */
private void addContentView(@NonNull final TabItem tabItem) {
    PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) tabItem.getViewHolder();
    View view = viewHolder.content;
    Tab tab = tabItem.getTab();

    if (view == null) {
        ViewGroup parent = viewHolder.contentContainer;
        Pair<View, ?> pair = tabViewRecycler.inflate(tab, parent);
        view = pair.first;
        LayoutParams layoutParams =
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        Rect padding = getPadding();
        layoutParams.setMargins(padding.left, padding.top, padding.right, padding.bottom);
        parent.addView(view, 0, layoutParams);
        viewHolder.content = view;
    } else {
        tabViewRecycler.getAdapter().onShowView(getModel().getContext(), view, tab, false);
    }

    viewHolder.previewImageView.setVisibility(View.GONE);
    viewHolder.previewImageView.setImageBitmap(null);
    viewHolder.borderView.setVisibility(View.GONE);
}
 
Example 2
Source File: CardFragment.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
            .getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}
 
Example 3
Source File: BasicNativePage.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
public BasicNativePage(Activity activity, Tab tab) {
    initialize(activity, tab);
    mActivity = activity;
    mTab = tab;
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    Resources res = mActivity.getResources();

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    getView().setLayoutParams(layoutParams);
}
 
Example 4
Source File: IconCardFragment.java    From ViewPagerTabIndicator with Artistic License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
Example 5
Source File: BasicNativePage.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public BasicNativePage(Activity activity, NativePageHost host) {
    initialize(activity, host);
    mActivity = activity;
    mHost = host;
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    Resources res = mActivity.getResources();

    int topMargin = 0;
    int bottomMargin = 0;
    if (activity instanceof ChromeActivity
            && ((ChromeActivity) activity).getBottomSheet() != null) {
        bottomMargin = res.getDimensionPixelSize(R.dimen.bottom_control_container_height);
    } else {
        topMargin = res.getDimensionPixelSize(R.dimen.tab_strip_height)
                + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow);
    }

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0, topMargin, 0, bottomMargin);
    getView().setLayoutParams(layoutParams);
}
 
Example 6
Source File: SuperAwesomeCardFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
Example 7
Source File: SuperAwesomeCardFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
Example 8
Source File: SuperAwesomeCardFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
       params.gravity = Gravity.CENTER;

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
Example 9
Source File: PhoneTabRecyclerAdapter.java    From ChromeLikeTabSwitcher with Apache License 2.0 5 votes vote down vote up
/**
 * Adapts the padding of a tab.
 *
 * @param viewHolder
 *         The view holder, which stores references to the tab's views, as an instance of the
 *         class {@link PhoneTabViewHolder}. The view holder may not be null
 */
private void adaptPadding(@NonNull final PhoneTabViewHolder viewHolder) {
    Rect padding = getPadding();

    if (viewHolder.content != null) {
        LayoutParams contentLayoutParams = (LayoutParams) viewHolder.content.getLayoutParams();
        contentLayoutParams
                .setMargins(padding.left, padding.top, padding.right, padding.bottom);
    }

    LayoutParams previewLayoutParams =
            (LayoutParams) viewHolder.previewImageView.getLayoutParams();
    previewLayoutParams.setMargins(padding.left, padding.top, padding.right, padding.bottom);
}
 
Example 10
Source File: PlayerFragment.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
/**
 * This function sets the closed caption data on the TextView
 */
private void setClosedCaptionData(Caption text){
    try{
        RelativeLayout subTitlesLayout = (RelativeLayout) getActivity().findViewById(R.id.txtSubtitles);
        TextView subTitlesTv = (TextView) getActivity().findViewById(R.id.txtSubtitles_tv);
        if(subTitlesTv!=null ){
            if(text!=null){
                int margin_twenty_dp = (int) UiUtil.getParamsInDP(getResources(),20);
                int margin_ten_dp = (int) UiUtil.getParamsInDP(getResources(),10);
                if(player!=null){
                    LayoutParams lp = (LayoutParams) subTitlesLayout.getLayoutParams();
                    if (player.getController()!=null && player.getController().isShown()){
                        if(player.isFullScreen()){
                            lp.setMargins(margin_twenty_dp, 0,
                                    margin_twenty_dp, (int)UiUtil.getParamsInDP(getResources(),50));
                        }else{
                            lp.setMargins(margin_twenty_dp, 0,
                                    margin_twenty_dp,(int)UiUtil.getParamsInDP(getResources(),42));
                        }
                        subTitlesLayout.setLayoutParams(lp);
                    }else{
                        if(player.isFullScreen()){
                            lp.setMargins(margin_twenty_dp, 0,
                                    margin_twenty_dp, margin_ten_dp);
                        }else{
                            lp.setMargins(margin_twenty_dp, 0,
                                    margin_twenty_dp,(int)UiUtil.getParamsInDP(getResources(),5));
                        }
                        subTitlesLayout.setLayoutParams(lp);
                    }
                }
                subTitlesTv.setPadding(margin_ten_dp, (int)UiUtil.getParamsInDP(getResources(),2),
                        margin_ten_dp,(int)UiUtil.getParamsInDP(getResources(),2) );
                subTitlesTv.setText("");
                //This has been done because text.content contains <br />
                //in the end of each message
                String temp = text.content;
                if(temp.endsWith("<br />")){
                    temp = temp.substring(0, temp.length()-6);
                }
                if(temp.length()==0){
                    subTitlesTv.setVisibility(View.GONE);
                }else{
                    subTitlesTv.setText(TextUtils.formatHtml(temp));
                    subTitlesTv.setVisibility(View.VISIBLE);
                }
            }else{
                subTitlesTv.setVisibility(View.GONE);
            }
        }
    }catch(Exception e){
        logger.error(e);
    }
}
 
Example 11
Source File: MapFragment.java    From maps-app-android with Apache License 2.0 4 votes vote down vote up
/**
 * Takes a MapView that has already been instantiated to show a WebMap,
 * completes its setup by setting various listeners and attributes, and sets
 * it as the activity's content view.
 *
 * @param mapView
 */
private void setMapView(final MapView mapView) {

	mMapView = mapView;
	mMapView.setWrapAroundMode(WrapAroundMode.ENABLE_WHEN_SUPPORTED);

	// Creating an inflater
	mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

	// Setting up the layout params for the searchview and searchresult
	// layout
	mlayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,
			Gravity.LEFT | Gravity.TOP);
	int LEFT_MARGIN_SEARCH = 15;
	int RIGHT_MARGIN_SEARCH = 15;
	int BOTTOM_MARGIN_SEARCH = 0;

	mlayoutParams.setMargins(LEFT_MARGIN_SEARCH, TOP_MARGIN_SEARCH, RIGHT_MARGIN_SEARCH, BOTTOM_MARGIN_SEARCH);

	// Displaying the searchbox layout
	showSearchBoxLayout();

	// Show current location
	mLocationDisplay = mapView.getLocationDisplay();
	mLocationDisplay.setAutoPanMode(LocationDisplay.AutoPanMode.RECENTER);
	mLocationDisplay.startAsync();

	mLocationDisplay.setInitialZoomScale(50000);

	// Handle any location changes
	mLocationDisplay.addLocationChangedListener(new LocationListener());


	// Setup use of magnifier on a long press on the map
	mMapView.setMagnifierEnabled(true);
	mLongPressEvent = null;

	// Setup OnTouchListener to detect and act on long-press
	mMapView.setOnTouchListener(new MapTouchListener(getActivity().getApplicationContext(), mMapView));

	mLocator = new LocatorTask(getString(R.string.geocode_url));
}