Example usage for android.widget LinearLayout LinearLayout

List of usage examples for android.widget LinearLayout LinearLayout

Introduction

In this page you can find the example usage for android.widget LinearLayout LinearLayout.

Prototype

public LinearLayout(Context context) 

Source Link

Usage

From source file:com.cssweb.android.base.QuoteGridActivity.java

protected void refreshHSZSUI(List<CssStock> list, String[] cols) throws JSONException {
    LinearLayout localLinearLayout1 = (LinearLayout) this.findViewById(R.id.zr_htable_lock);
    LinearLayout localLinearLayout2 = (LinearLayout) this.findViewById(R.id.zr_htable_linearlayout);
    this.mLinerLock = localLinearLayout1;
    this.mLinerHScroll = localLinearLayout2;
    this.mLinerLock.removeAllViews();
    this.mLinerHScroll.removeAllViews();

    if (nameOrcode)
        AddViewItem(cols[0], Utils.getTextColor(mContext, 0), mLinerLock, -1, 0, 0, true);
    else/*from  w  ww .j av a2  s .c o  m*/
        AddViewItem(cols[1], Utils.getTextColor(mContext, 0), mLinerLock, -1, 0, 0, true);

    LinearLayout l1 = new LinearLayout(this);
    for (int i = 2; i < cols.length; i++) {
        if (i == cols.length - 1)
            AddViewItem(cols[i], Utils.getTextColor(mContext, 0), l1, -i, 100, 0, true);
        else
            AddViewItem(cols[i], Utils.getTextColor(mContext, 0), l1, -i, i - 1, 0, true);
    }

    mLinerHScroll.addView(l1);

    int mDigit = 1;
    double d0 = 0;
    for (int i = 1; i <= list.size(); i++) {
        CssStock cs = list.get(i - 1);
        try {
            d0 = cs.getZrsp();
            //??
            mDigit = Utils.getNumFormat(cs.getMarket(), cs.getStkcode());
            if (nameOrcode)
                AddViewItem(cs.getStkname(), Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
            else
                AddViewItem(cs.getStkcode(), Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);

            l1 = new LinearLayout(this);
            l1.setTag(i);

            if (cs.getStkcode() == null || cs.getStkcode().equals("") || cs.getStkname() == null
                    || cs.getStkname().equals("")) {
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 1, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 2, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 3, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 4, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 5, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 6, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 7, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 8, i, false);
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 9, i, false);

            } else {
                String str1;
                if (cs.getZf() == 0)
                    str1 = Utils.dataFormation(cs.getZf() * 100, 1);
                else
                    str1 = Utils.dataFormation(cs.getZf() * 100, 1);
                AddViewItem(Utils.dataFormation(cs.getZjcj(), mDigit),
                        Utils.getTextColor(mContext, cs.getZjcj(), d0), l1, i, 1, i, true);
                AddViewItem(str1, Utils.getTextColor(mContext, cs.getZf()), l1, i, 2, i, true);
                AddViewItem(Utils.dataFormation(cs.getZd(), mDigit), Utils.getTextColor(mContext, cs.getZd()),
                        l1, i, 3, i, true);

                AddViewItem(Utils.getAmountFormat(cs.getZje(), false, 1), Utils.getTextColor(mContext, 2), l1,
                        i, 4, i, true);

                AddViewItem(Utils.dataFormation(cs.getJrkp(), mDigit),
                        Utils.getTextColor(mContext, cs.getJrkp(), d0), l1, i, 5, i, true);
                AddViewItem(Utils.dataFormation(cs.getZrsp(), mDigit), Utils.getTextColor(mContext, 0), l1, i,
                        6, i, true);
                AddViewItem(Utils.dataFormation(cs.getZgcj(), mDigit),
                        Utils.getTextColor(mContext, cs.getZgcj(), d0), l1, i, 7, i, true);
                AddViewItem(Utils.dataFormation(cs.getZdcj(), mDigit),
                        Utils.getTextColor(mContext, cs.getZdcj(), d0), l1, i, 8, i, true);
                AddViewItem(Utils.dataFormation(cs.getAmp() * 100, 1) + "%", Utils.getTextColor(mContext, 5),
                        l1, i, 100, i, true);

            }
        } catch (Exception e) {
            for (int j = 1; j <= len - 2; j++) {
                AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, j, i, false);
            }
            e.printStackTrace();
        }

        mLinerHScroll.addView(l1);
    }
}

From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);// w ww .  j  av  a 2  s  .  c  om
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.example.team04adventure.Controller.OnlineStoryList.java

/**
 * Shows the help information for this fragment.
 *///from   w w  w  . ja  v a  2 s.  co  m
private void help() {
    String helpText = "All stories are displayed here. Press a story to read it. Online stories contains all"
            + "the stories on the server. My stories contains all the stories written by you."
            + "Cached stories contains all the stories downloaded on your phone that aren't written by you. "
            + "The 'I'm Feeling Lucky!' button chooses a random story for you from the existing online stories."
            + "The 'Add Story' button lets you create a new story, and new stories can only be published by creating a"
            + "new story from here. The 'Sync' button locally mirrors the cached stories with the online stories so that"
            + "the cached stories are updated.";
    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    LinearLayout lila1 = new LinearLayout(this);
    lila1.setOrientation(1);

    final TextView helpTextView = new TextView(this);
    helpTextView.setText(helpText);
    lila1.addView(helpTextView);
    adb.setView(lila1);
    adb.setTitle("Help");

    adb.show();
}

From source file:com.admin.control.ab.AbSlidingPlayView.java

/**
 * ???View.//from w ww .  j ava  2 s. c  o m
 *
 * @param context the context
 */
public void initView(Context context) {
    this.context = context;
    //TODO >>
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    //TODO <<
    navLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);
    mViewPager = new AbInnerViewPager(context);
    //ViewPager,fragmentsetId()id
    //        mViewPager.setId(1985);
    //
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout, layoutParamsFW);
    //        addView(mRelativeLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    //?
    displayImage = ABFileUtil.getBitmapFromSrc("play_display.png");
    hideImage = ABFileUtil.getBitmapFromSrc("play_hide.png");

    mListViews = new ArrayList<>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            if (mAbScrolledListener != null) {
                if (position == 0)
                    mAbScrolledListener.onScrollToLeft();
                if (position == mListViews.size() - 1)
                    mAbScrolledListener.onScrollToRight();
            }
            setNowPlayIndex(position);
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java

@Override
public void refresh() {
    new AsyncTask<Void, Void, Void>() {
        @Override/*from  ww w.j a va  2  s  .c om*/
        protected Void doInBackground(Void... params) {
            final String instanceId = mInstanceIdHelper.getInstanceId();
            final String creationTime = DateFormat.getDateTimeInstance()
                    .format(new Date(mInstanceIdHelper.getCreationTime()));
            final Activity activity = getActivity();
            if (activity != null) {
                Handler handler = new Handler(activity.getMainLooper());
                handler.post(new Runnable() {
                    public void run() {
                        setValue(activity.findViewById(R.id.iid_instance_id), instanceId);
                        setValue(activity.findViewById(R.id.iid_creation_time), creationTime);
                    }
                });
            }
            return null;
        }
    }.execute();
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        if (sender.appTokens.size() > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Token token : sender.appTokens.values()) {
                LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                        .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                icon.setImageResource(R.drawable.smartphone_grey600);
                label.setText(token.scope + " - " + AbstractFragment.truncateToMediumString(token.token));
                button.setText(R.string.iid_delete_token);
                button.setTag(R.id.tag_senderid, sender.senderId);
                button.setTag(R.id.tag_scope, token.scope);
                button.setOnClickListener(this);
                row.setPadding((int) (16 * density), 0, 0, 0);
                sendersList.addView(row);
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.iid_no_tokens));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper);
    tokensView.removeAllViews();
    tokensView.addView(sendersList);
}

From source file:com.freud.mrzz.views.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from ww  w . j  av a  2 s  . co m
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    if (colorStateList != null) {
        tabTextColor = colorStateList;
    } else {
        tabTextColor = getColorStateList(textPrimaryColor);
    }

    underlineColor = textPrimaryColor;
    dividerColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    int paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, padding);
    int paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, padding);
    a.recycle();

    //In case we have the padding they must be equal so we take the biggest
    if (paddingRight < paddingLeft) {
        padding = paddingLeft;
    }

    if (paddingLeft < paddingRight) {
        padding = paddingRight;
    }

    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
    tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
    tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
    a.recycle();

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.quarterfull.newsAndroid.ListView.SubscriptionExpandableListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {//from   ww  w .jav a  2s.  c om
    final ConcreteFeedItem item = (ConcreteFeedItem) getChild(groupPosition, childPosition);
    final ChildHolder viewHolder;

    if (convertView != null) {
        viewHolder = (ChildHolder) convertView.getTag();
    } else {
        LinearLayout view = new LinearLayout(mContext);
        convertView = inflater.inflate(R.layout.subscription_list_sub_item, view, true);
        viewHolder = new ChildHolder(convertView);
        convertView.setTag(viewHolder);
    }

    if (item != null) {
        String headerText = (item.header != null) ? item.header : "";
        viewHolder.tV_HeaderText.setText(headerText);

        String unreadCount;
        if (item.idFolder == ALL_STARRED_ITEMS.getValue()) {
            unreadCount = starredCountFeeds.get((int) item.id_database);
        } else {
            unreadCount = unreadCountFeeds.get((int) item.id_database);
        }

        if (unreadCount != null)
            viewHolder.tV_UnreadCount.setText(unreadCount);
        else
            viewHolder.tV_UnreadCount.setText("");

        favIconHandler.loadFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon);
    } else {
        viewHolder.tV_HeaderText.setText(mContext.getString(R.string.login_dialog_text_something_went_wrong));
        viewHolder.tV_UnreadCount.setText("");
        viewHolder.imgView_FavIcon.setImageDrawable(null);
    }

    return convertView;
}

From source file:edu.cscie71.imm.slacker.plugin.Slacker.java

private void openAuthScreen() {
    Runnable runnable = new Runnable() {
        @SuppressLint("NewApi")
        public void run() {
            dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);/*from w  w w  .  j a v  a2  s .co  m*/

            LinearLayout mainLayout = new LinearLayout(cordova.getActivity());
            mainLayout.setOrientation(LinearLayout.VERTICAL);

            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new WebChromeClient());
            WebViewClient client = new AuthBrowser();
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);

            inAppWebView.loadUrl(authURL + "?client_id=" + slackClientID + "&scope=" + scope);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            mainLayout.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(mainLayout);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

public PagerSlidingTabStripPlus(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true); // ScrollView stretch his content height to fill his viewport
    setWillNotDraw(false);/*from  w ww. j  a va 2 s  .c  om*/

    // Layout parameters
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    // Converting values to floating point value
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPaddingLeft = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingLeft, dm);
    tabPaddingRight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingRight, dm);
    tabPaddingTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingTop, dm);
    tabPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingBottom, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStripPlus);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStripPlus_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsDividerPadding,
            dividerPadding);
    tabPaddingLeft = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingLeft,
            tabPaddingLeft);
    tabPaddingRight = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingRight,
            tabPaddingRight);
    tabPaddingTop = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingTop,
            tabPaddingTop);
    tabPaddingBottom = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStripPlus_pstsTabPaddingBottom,
            tabPaddingBottom);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStripPlus_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsTextAllCaps, textAllCaps);
    textColorTab = a.getColorStateList(R.styleable.PagerSlidingTabStripPlus_pstsTextColorTab);
    indicatorAlpha = a.getInteger(R.styleable.PagerSlidingTabStripPlus_pstsIndicatorAlpha, indicatorAlpha);
    hasDivider = a.getBoolean(R.styleable.PagerSlidingTabStripPlus_pstsHasDivider, hasDivider);
    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStripPlus_pstsTabTextSize, tabTextSize);
    tabsGravity = a.getInteger(R.styleable.PagerSlidingTabStripPlus_pstsTabsTitleGravity, tabsGravity);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }

}

From source file:org.openremote.android.console.AppSettingsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setTitle(R.string.settings);/*from ww w . ja  va  2 s  .co m*/

    this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this);

    // The main layout contains all application configuration items.
    LinearLayout mainLayout = new LinearLayout(this);
    mainLayout
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mainLayout.setOrientation(LinearLayout.VERTICAL);
    mainLayout.setBackgroundColor(0);
    mainLayout.setTag(R.string.settings);

    loadingPanelProgress = new ProgressDialog(this);

    // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled.
    ScrollView scroll = new ScrollView(this);
    scroll.setVerticalScrollBarEnabled(true);
    scroll.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
    appSettingsView = new LinearLayout(this);
    appSettingsView
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    appSettingsView.setOrientation(LinearLayout.VERTICAL);

    appSettingsView.addView(createAutoLayout());
    appSettingsView.addView(createChooseControllerLabel());

    currentServer = "";
    if (autoMode) {
        appSettingsView.addView(constructAutoServersView());
    } else {
        appSettingsView.addView(constructCustomServersView());
    }
    appSettingsView.addView(createChoosePanelLabel());
    panelSelectSpinnerView = new PanelSelectSpinnerView(this);
    appSettingsView.addView(panelSelectSpinnerView);

    appSettingsView.addView(createCacheText());
    appSettingsView.addView(createClearImageCacheButton());
    appSettingsView.addView(createSSLLayout());
    scroll.addView(appSettingsView);

    mainLayout.addView(scroll);
    mainLayout.addView(createDoneAndCancelLayout());

    setContentView(mainLayout);
    initSSLState();
    addOnclickListenerOnDoneButton();
    addOnclickListenerOnCancelButton();
    progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress);

}