Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    if (mLeftViewId != 0 && mSwipeLeftHorizontal == null) {
        View view = findViewById(mLeftViewId);
        mSwipeLeftHorizontal = new SwipeLeftHorizontal(view);
    }/*from ww  w.  ja va  2  s .c  o  m*/
    if (mRightViewId != 0 && mSwipeRightHorizontal == null) {
        View view = findViewById(mRightViewId);
        mSwipeRightHorizontal = new SwipeRightHorizontal(view);
    }
    if (mContentViewId != 0 && mContentView == null) {
        mContentView = findViewById(mContentViewId);
    } else {
        TextView errorView = new TextView(getContext());
        errorView.setClickable(true);
        errorView.setGravity(Gravity.CENTER);
        errorView.setTextSize(16);
        errorView.setText("You may not have set the ContentView.");
        mContentView = errorView;
        addView(mContentView);
    }
}

From source file:com.facebook.android.MainPage.java

/** Called when the activity is first created. */
@Override//from   w  ww .  j  a  v  a  2 s. c  o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (APP_ID == null) {
        Util.showAlert(this, "Warning",
                "Facebook Applicaton ID must be " + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);
    mMovieNameInput = (EditText) findViewById(R.id.title);
    mMediaSpinner = (Spinner) findViewById(R.id.media);
    mSearchButton = (Button) findViewById(R.id.search);
    mFacebook = new Facebook(APP_ID);
    mAsyncRunner = new AsyncFacebookRunner(mFacebook);

    SessionStore.restore(mFacebook, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());
    // set up the Spinner for the media list selection
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.media_list,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMediaSpinner.setAdapter(adapter);

    //for search button         
    final Context context = this;
    mSearchButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            String servletURL;
            String movieName = mMovieNameInput.getText().toString();
            // check the input text of movie, if the text is empty give user alert
            movieName = movieName.trim();
            if (movieName.length() == 0) {
                Toast toast = Toast.makeText(context, "Please enter a movie name", Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 70);
                toast.show();
            }
            // if movie name is not empty
            else {
                // remove any extra whitespace
                movieName = movieName.replaceAll("\\s+", "+");
                String mediaList = mMediaSpinner.getSelectedItem().toString();
                if (mediaList.equals("Feature Film")) {
                    mediaList = "feature";
                }
                mediaList = mediaList.replaceAll("\\s+", "+");
                // construct the query string
                // construct the final URL to Servlet
                //String servletString = "?" + "title=" + movieName + "&" + "title_type=" + mediaList;
                //servletURL = "http://cs-server.usc.edu:10854/examples/servlet/Amovie"
                //+ servletString;
                //String servletString = "?" + "title=" + movieName + "&" + "media=" + mediaList;
                //servletURL = "http://cs-server.usc.edu:34404/examples/servlet/HelloWorldExample?title=" + movieName + "&" + "media=" + mediaList;
                //+ servletString;
                servletURL = "http://cs-server.usc.edu:10854/examples/servlet/Amovie?title=" + movieName + "&"
                        + "title_type=" + mediaList;
                BufferedReader in = null;
                try {
                    // REFERENCE: this part of code is modified from:
                    // "Example of HTTP GET Request using HttpClient in Android"
                    // http://w3mentor.com/learn/java/android-development/android-http-services/example-of-http-get-request-using-httpclient-in-android/
                    // get response (JSON string) from Servlet 
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet();
                    request.setURI(new URI(servletURL));
                    HttpResponse response = client.execute(request);
                    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                    StringBuffer sb = new StringBuffer("");
                    String line = "";
                    String NL = System.getProperty("line.separator");
                    while ((line = in.readLine()) != null) {
                        sb.append(line + NL);
                    }
                    in.close();
                    String page = sb.toString();
                    //test for JSON string
                    /*LinearLayout lView = new LinearLayout(context);
                    TextView myText = new TextView(context);
                    myText.setText(page);
                    lView.addView(myText);
                    setContentView(lView);*/

                    // convert the JSON string to real JSON and get out the movie JSON array
                    // to check if there is any movie data
                    JSONObject finalJson;
                    JSONObject movieJson;
                    JSONArray movieJsonArray;
                    finalJson = new JSONObject(page);
                    movieJson = finalJson.getJSONObject("results");
                    //System.out.println(movieJson);
                    movieJsonArray = movieJson.getJSONArray("result");

                    // if the response contains some movie data
                    if (movieJsonArray.length() != 0) {

                        // start the ListView activity, and pass the JSON string to it
                        Intent intent = new Intent(context, MovieListActivity.class);
                        intent.putExtra("finalJson", page);
                        startActivity(intent);
                    }
                    // if the response does not contain any movie data,
                    // show user that there is no result for this search
                    else {
                        Toast toast = Toast.makeText(getBaseContext(), "No movie found for this search",
                                Toast.LENGTH_LONG);
                        toast.setGravity(Gravity.CENTER, 0, 0);
                        toast.show();
                    }
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    });
}

From source file:im.afterclass.android.activity.InvitePickActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_invite_pick_contacts);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // String groupName = getIntent().getStringExtra("groupName");
    String groupId = getIntent().getStringExtra("groupId");
    if (groupId == null) {// 
        isCreatingNewGroup = true;//from  www.  j  a  v a  2s . co  m
    } else {
        // ??
        EMGroup group = EMGroupManager.getInstance().getGroup(groupId);
        exitingMembers = group.getMembers();
    }
    if (exitingMembers == null)
        exitingMembers = new ArrayList<String>();
    // ??
    final List<User> alluserList = new ArrayList<User>();
    for (User user : DemoApplication.getInstance().getContactList().values()) {
        if (!user.getUsername().equals(Constant.NEW_FRIENDS_USERNAME)
                & !user.getUsername().equals(Constant.GROUP_USERNAME))
            alluserList.add(user);
    }
    // list?
    Collections.sort(alluserList, new Comparator<User>() {
        @Override
        public int compare(User lhs, User rhs) {
            return (lhs.getUsername().compareTo(rhs.getUsername()));

        }
    });

    contactSelected = (LinearLayout) findViewById(R.id.contact_selected);
    params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    params.leftMargin = 10;
    params.topMargin = 5;
    params.gravity = Gravity.CENTER;
    gridView = (GridView) findViewById(R.id.gridview);
    //listView = (ListView) findViewById(R.id.list);
    contactAdapter = new PickContactAdapter(this, R.layout.contact_gridview_item, alluserList);
    gridView.setAdapter(contactAdapter);

    //      doPost();
}

From source file:com.facebook.notifications.internal.content.TextContent.java

@Override
public void applyTo(@NonNull View view) {
    if (view instanceof TextView) {
        TextView textView = (TextView) view;

        textView.setText(getText());//www.  j a  v  a 2  s  . c  o m
        textView.setTextColor(getTextColor());

        Typeface typeface = FontUtilities.parseFont(getTypeface());
        typeface = typeface != null ? typeface : Typeface.DEFAULT;

        textView.setTypeface(typeface);
        textView.setTextSize(getTypefaceSize());

        switch (getTextAlignment()) {
        case Left:
            textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
            break;

        case Center:
            textView.setGravity(Gravity.CENTER);
            break;

        case Right:
            textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            break;
        }
    }
}

From source file:com.ab.view.sliding.AbSlidingTabView.java

/**
 * Instantiates a new ab sliding tab view.
 *
 * @param context the context//www  .  j  a  va  2s . c om
 * @param attrs the attrs
 */
public AbSlidingTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new HorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

}

From source file:com.mikecorrigan.trainscorekeeper.FragmentSummary.java

@SuppressLint("NewApi")
@Override/*from ww  w .j  a  v  a  2  s .  com*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container
            + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState));

    View rootView = inflater.inflate(R.layout.fragment_summary, container, false);

    final MainActivity activity = (MainActivity) getActivity();
    final Context context = activity;
    final Resources resources = context.getResources();

    // Get the model and attach a listener.
    game = activity.getGame();
    if (game != null) {
        game.addListener(mGameListener);
    }

    players = activity.getPlayers();

    // Get resources.
    String[] playerNames = resources.getStringArray(R.array.playerNames);

    TypedArray drawablesArray = resources.obtainTypedArray(R.array.playerDrawables);

    TypedArray playerTextColorsArray = resources.obtainTypedArray(R.array.playerTextColors);
    int[] playerTextColorsIds = new int[playerTextColorsArray.length()];
    for (int i = 0; i < playerTextColorsArray.length(); i++) {
        playerTextColorsIds[i] = playerTextColorsArray.getResourceId(i, -1);
    }

    // Get root view.
    ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view);

    // Create table.
    tableLayout = new TableLayout(context);
    TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tableLayout.setLayoutParams(tableLayoutParams);
    scrollView.addView(tableLayout);

    // Add header.
    {
        TableRow row = new TableRow(context);
        row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        tableLayout.addView(row);

        TextView tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.player));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.trains));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.contracts));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.bonuses));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

    }

    // Add rows.
    for (int i = 0; i < players.getNum(); i++) {
        TableRow row = new TableRow(context);
        row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        tableLayout.addView(row);

        ToggleButton toggleButton = new ToggleButton(context);
        toggleButton.setGravity(Gravity.CENTER);
        toggleButton.setPadding(10, 10, 10, 10);
        toggleButton.setText(playerNames[i]);
        toggleButton.setClickable(false);
        Drawable drawable = drawablesArray.getDrawable(i);
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            toggleButton.setBackgroundDrawable(drawable);
        } else {
            toggleButton.setBackground(drawable);
        }
        toggleButton.setTextColor(resources.getColor(playerTextColorsIds[i]));
        row.addView(toggleButton);

        TextView tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

    }

    Bundle args = getArguments();
    if (args == null) {
        Log.e(TAG, "onCreateView: missing arguments");
        return rootView;
    }

    drawablesArray.recycle();
    playerTextColorsArray.recycle();

    // final int index = args.getInt(ARG_INDEX);
    // final String tabSpec = args.getString(ARG_TAB_SPEC);

    return rootView;
}

From source file:com.insthub.O2OMobile.Activity.G0_ReportActivity.java

@Override
public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException {
    // TODO Auto-generated method stub
    if (url.endsWith(ApiInterface.REPORT)) {
        ToastView toast = new ToastView(this, getString(R.string.complain_success));
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();/* w ww.ja  v a  2s .c  o  m*/
        finish();
    }
}

From source file:com.ab.view.sliding.AbSlidingTabView2.java

public AbSlidingTabView2(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout/*  ww w. j  a  v a2  s  .  co  m*/
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        Log.e(TAG, "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            if (D)
                Log.d(TAG, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            if (D)
                Log.d(TAG, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            if (D)
                Log.d(TAG, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            if (D)
                Log.d(TAG, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context//from   w w w . ja va2  s .c  om
 * @param attrs the attrs
 */
public ESSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new ESHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        ESLogUtil.e(ESSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            ESLogUtil.d(ESSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:com.auth0.android.lock.views.FormLayout.java

private void init() {
    boolean showSocial = !lockWidget.getConfiguration().getSocialConnections().isEmpty();
    showDatabase = lockWidget.getConfiguration().getDatabaseConnection() != null;
    showEnterprise = !lockWidget.getConfiguration().getEnterpriseConnections().isEmpty();
    boolean showModeSelection = showDatabase && lockWidget.getConfiguration().allowLogIn()
            && lockWidget.getConfiguration().allowSignUp();

    int verticalMargin = getResources()
            .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
    int horizontalMargin = getResources()
            .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);

    if (showModeSelection) {
        Log.v(TAG, "Showing the LogIn/SignUp tabs");
        modeSelectionView = new ModeSelectionView(getContext(), this);
        modeSelectionView.setId(R.id.com_auth0_lock_form_selector);
        LayoutParams modeSelectionParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        modeSelectionParams.addRule(ALIGN_PARENT_TOP);
        addView(modeSelectionView, modeSelectionParams);
    }/*from  w  w w.j  a v a 2s  .  c o  m*/
    formsHolder = new LinearLayout(getContext());
    formsHolder.setOrientation(LinearLayout.VERTICAL);
    formsHolder.setGravity(Gravity.CENTER);
    formsHolder.setPadding(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
    LayoutParams holderParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    holderParams.addRule(BELOW, R.id.com_auth0_lock_form_selector);
    holderParams.addRule(CENTER_VERTICAL);
    addView(formsHolder, holderParams);

    if (showSocial) {
        addSocialLayout();
        if (showDatabase || showEnterprise) {
            addSeparator();
        }
    }
    displayInitialScreen();
}