Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

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

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:com.iStudy.Study.Renren.View.RenrenDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    progress = new ProgressDialog(getContext());
    progress.requestWindowFeature(Window.FEATURE_NO_TITLE);
    progress.setMessage("Loading...");

    content = new LinearLayout(getContext());
    content.setOrientation(LinearLayout.VERTICAL);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (this.showTitle) {
        setUpTitle();/*www.  j  a v a  2  s . c o m*/
    }
    setUpWebView();

    Display display = getWindow().getWindowManager().getDefaultDisplay();
    float scale = getContext().getResources().getDisplayMetrics().density;
    @SuppressWarnings("deprecation")
    float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
    addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
            (int) (dimensions[1] * scale + 0.5f)));
}

From source file:com.sonnychen.aviationhk.views.RadarFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_radar, container, false);
    RecyclerView mListView = (RecyclerView) view.findViewById(R.id.listView);

    cardList.clear();//from  www .  ja  v a  2  s. c o m
    for (Pair<String, String> cam : BaseApplication.Data.WeatherPhotoURLs) {
        cardList.add(new GenericCardItem(cam.first, cam.second, cam.first));
    }

    GridLayoutManager mLayoutManager = new GridLayoutManager(getContext(), 2, LinearLayoutManager.VERTICAL,
            false);
    mLayoutManager.setAutoMeasureEnabled(true);
    mLayoutManager.setMeasurementCacheEnabled(false);
    mListView.setLayoutManager(mLayoutManager);
    mListView.setHasFixedSize(false);
    mListView.setAdapter(new GenericRecyclerViewAdapter(getContext(), cardList, LinearLayout.VERTICAL));
    return view;
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.TextModalInteractionView.java

@Override
public void doOnCreate(final Activity activity, Bundle onSavedInstanceState) {
    activity.setContentView(R.layout.apptentive_textmodal_interaction_center);

    TextView title = (TextView) activity.findViewById(R.id.title);
    if (interaction.getTitle() == null) {
        title.setVisibility(View.GONE);
    } else {//from  w w  w . ja v a 2  s  .  c  om
        title.setText(interaction.getTitle());
    }
    TextView body = (TextView) activity.findViewById(R.id.body);
    if (interaction.getBody() == null) {
        body.setVisibility(View.GONE);
    } else {
        body.setText(interaction.getBody());
    }

    LinearLayout bottomArea = (LinearLayout) activity.findViewById(R.id.bottom_area);
    List<Action> actions = interaction.getActions().getAsList();
    boolean vertical;
    if (actions != null && !actions.isEmpty()) {
        int totalChars = 0;
        for (Action button : actions) {
            totalChars += button.getLabel().length();
        }
        if (actions.size() == 1) {
            vertical = false;
        } else if (actions.size() == 2) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_TWO_BUTTONS;
        } else if (actions.size() == 3) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_THREE_BUTTONS;
        } else if (actions.size() == 4) {
            vertical = totalChars > MAX_TEXT_LENGTH_FOR_FOUR_BUTTONS;
        } else {
            vertical = true;
        }
        if (vertical) {
            bottomArea.setOrientation(LinearLayout.VERTICAL);
        } else {
            bottomArea.setOrientation(LinearLayout.HORIZONTAL);
        }

        for (int i = 0; i < actions.size(); i++) {
            final Action buttonAction = actions.get(i);
            final int position = i;
            ApptentiveDialogButton button = new ApptentiveDialogButton(activity);
            button.setText(buttonAction.getLabel());
            switch (buttonAction.getType()) {
            case dismiss:
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        JSONObject data = new JSONObject();
                        try {
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId());
                            data.put(Action.KEY_LABEL, buttonAction.getLabel());
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position);
                        } catch (JSONException e) {
                            Log.e("Error creating Event data object.", e);
                        }
                        EngagementModule.engageInternal(activity, interaction,
                                TextModalInteraction.EVENT_NAME_DISMISS, data.toString());
                        activity.finish();
                    }
                });
                break;
            case interaction:
                button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        LaunchInteractionAction launchInteractionButton = (LaunchInteractionAction) buttonAction;
                        List<Invocation> invocations = launchInteractionButton.getInvocations();
                        String interactionIdToLaunch = null;
                        for (Invocation invocation : invocations) {
                            if (invocation.isCriteriaMet(activity)) {
                                interactionIdToLaunch = invocation.getInteractionId();
                                break;
                            }
                        }

                        Interaction invokedInteraction = null;
                        if (interactionIdToLaunch != null) {
                            Interactions interactions = InteractionManager.getInteractions(activity);
                            if (interactions != null) {
                                invokedInteraction = interactions.getInteraction(interactionIdToLaunch);
                            }
                        }

                        JSONObject data = new JSONObject();
                        try {
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_ID, buttonAction.getId());
                            data.put(Action.KEY_LABEL, buttonAction.getLabel());
                            data.put(TextModalInteraction.EVENT_KEY_ACTION_POSITION, position);
                            data.put(TextModalInteraction.EVENT_KEY_INVOKED_INTERACTION_ID,
                                    invokedInteraction == null ? JSONObject.NULL : invokedInteraction.getId());
                        } catch (JSONException e) {
                            Log.e("Error creating Event data object.", e);
                        }

                        EngagementModule.engageInternal(activity, interaction,
                                TextModalInteraction.EVENT_NAME_INTERACTION, data.toString());
                        if (invokedInteraction != null) {
                            EngagementModule.launchInteraction(activity, invokedInteraction);
                        }

                        activity.finish();
                    }
                });
                break;
            }
            bottomArea.addView(button);
        }
    } else {
        bottomArea.setVisibility(View.GONE);
    }
}

From source file:com.ztspeech.weibo.sdk.renren.view.RenrenDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    progress = new ProgressDialog(getContext(), R.style.mydialog);
    progress.requestWindowFeature(Window.FEATURE_NO_TITLE);
    progress.setMessage("...");
    progress.setCanceledOnTouchOutside(false);
    content = new LinearLayout(getContext());
    content.setOrientation(LinearLayout.VERTICAL);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (this.showTitle) {
        setUpTitle();//from  w  ww  .  j ava2s.  c  o m
    }
    setUpWebView();

    Display display = getWindow().getWindowManager().getDefaultDisplay();
    float scale = getContext().getResources().getDisplayMetrics().density;
    float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
    addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
            (int) (dimensions[1] * scale + 0.5f)));
}

From source file:com.scxrh.amb.widget.FragmentTabHostState.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 LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from ww  w .  j ava  2s.c o m*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_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.FILL_PARENT, 0, 1));
    }
}

From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *//*from   ww  w .  ja v  a  2s. c o m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    //QUICK Inflate from XML file

    //inflater.inflate(R.layout.search_list_detail, root);
    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    RelativeLayout rlayout = new RelativeLayout(context);

    EditText et = new EditText(getActivity());
    et.setId(INTERNAL_SEARCH_FIELD_ID);
    et.setSingleLine(true);
    et.setInputType(InputType.TYPE_CLASS_TEXT);
    et.setImeOptions(EditorInfo.IME_ACTION_DONE);
    RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    rlayout.addView(et, etRLayoutParams);
    rlayout.addView(lframe, lframeRLayoutParams);
    root.addView(rlayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.weizoo.game.go.HappyGo.HappyGo.java

private void initAd() {
    try {//from  w  w  w  . j av  a2  s . c om
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        // Create the adView.
        adView = new AdView(this, AdSize.SMART_BANNER, "a152c6a39379a40");

        // Add the adView to it.
        layout.addView(adView);

        // Initiate a generic request.
        AdRequest adRequest = new AdRequest();
        adRequest.addTestDevice("355296050198170");
        // Load the adView with the ad request.
        adView.loadAd(adRequest);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.umeng.common.ui.emoji.EmojiBorad.java

/**
 * init. Set params and add show emoji views</br>
 *///from w ww.  j  av  a  2 s.  c  om
private void init() {
    computeBoardHeight();
    setOrientation(LinearLayout.VERTICAL);

    setBackgroundColor(Color.parseColor("#f4f4f6"));
    ViewPager viewPager = createVIewpager();
    addView(viewPager);
    ViewGroup container = createPointLinearlayout();
    List<EmojiView> datas = new ArrayList<EmojiView>();

    int lens = People.DATA.length;
    int pages = lens / PAGE_SIZE; // pages?
    for (int i = 0; i < pages; i++) {
        EmojiBean[] blocks = new EmojiBean[PAGE_SIZE + 1];
        System.arraycopy(People.DATA, i * PAGE_SIZE, blocks, 0, blocks.length - 1);
        blocks[PAGE_SIZE] = EmojiBean.fromChars(DELETE_KEY);
        datas.add(new EmojiView(getContext(), blocks)); // the last is
        // delete icon
    }
    // add remain emoji view
    if (pages * PAGE_SIZE < lens) {
        EmojiBean[] blocks = new EmojiBean[lens - pages * PAGE_SIZE];
        System.arraycopy(People.DATA, pages * PAGE_SIZE, blocks, 0, blocks.length);
        datas.add(new EmojiView(getContext(), blocks));
    }

    // add indicator
    for (int i = 0; i < datas.size(); i++) {
        ImageView indicatorView = createIndicator();
        mIndicators.add(indicatorView);
        container.addView(indicatorView);
    }
    addView(container);
    size = datas.size();
    // set cache view count
    viewPager.setOffscreenPageLimit(datas.size());
    // 
    mIndicators.get(mLastSelectViewPos).setImageDrawable(ColorQueque.getDrawable(mSelectIcon));
    mAdapter = new EmojiPagerAdapter(getContext(), datas);
    viewPager.setAdapter(mAdapter);
    viewPager.setOnPageChangeListener(this);
}

From source file:net.abcdroid.devfest12.ui.tablet.MapMultiPaneActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);

    LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer);
    spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
    spacerView.setGravity(landscape ? Gravity.RIGHT : Gravity.BOTTOM);

    View popupView = findViewById(R.id.map_detail_popup);
    LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams();
    popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
    popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0;
    popupView.setLayoutParams(popupLayoutParams);

    popupView.requestLayout();/*from   ww  w.j a  v a2 s .  c  om*/
}

From source file:org.quantumbadger.redreader.activities.AlbumListingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    PrefsUtility.applyTheme(this);

    OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album));

    if (getActionBar() != null) {
        getActionBar().setHomeButtonEnabled(true);
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }/*w  w  w .ja  va 2  s .  c  o m*/

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences)
            && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT;

    if (solidblack)
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));

    final Intent intent = getIntent();

    mUrl = intent.getDataString();

    if (mUrl == null) {
        finish();
        return;
    }

    final Matcher matchImgur = LinkHandler.imgurAlbumPattern.matcher(mUrl);
    final String albumId;

    if (matchImgur.find()) {
        albumId = matchImgur.group(2);
    } else {
        Log.e("AlbumListingActivity", "URL match failed");
        revertToWeb();
        return;
    }

    Log.i("AlbumListingActivity", "Loading URL " + mUrl + ", album id " + albumId);

    final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setIndeterminate(true);

    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(progressBar);

    ImgurAPI.getAlbumInfo(this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetAlbumInfoListener() {

        @Override
        public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status,
                final String readableMessage) {
            Log.e("AlbumListingActivity", "getAlbumInfo call failed: " + type);

            if (status != null)
                Log.e("AlbumListingActivity", "status was: " + status.toString());
            if (t != null)
                Log.e("AlbumListingActivity", "exception was: ", t);

            // It might be a single image, not an album

            if (status == null) {
                revertToWeb();
                return;
            }

            ImgurAPI.getImageInfo(AlbumListingActivity.this, albumId, Constants.Priority.IMAGE_VIEW, 0,
                    new GetImageInfoListener() {
                        @Override
                        public void onFailure(final RequestFailureType type, final Throwable t,
                                final StatusLine status, final String readableMessage) {
                            Log.e("AlbumListingActivity", "Image info request also failed: " + type);
                            revertToWeb();
                        }

                        @Override
                        public void onSuccess(final ImageInfo info) {
                            Log.i("AlbumListingActivity", "Link was actually an image.");
                            LinkHandler.onLinkClicked(AlbumListingActivity.this, info.urlOriginal);
                            finish();
                        }

                        @Override
                        public void onNotAnImage() {
                            Log.i("AlbumListingActivity", "Not an image either");
                            revertToWeb();
                        }
                    });
        }

        @Override
        public void onSuccess(final ImgurAPI.AlbumInfo info) {
            Log.i("AlbumListingActivity", "Got album, " + info.images.size() + " image(s)");

            AndroidApi.UI_THREAD_HANDLER.post(new Runnable() {
                @Override
                public void run() {

                    if (info.title != null && !info.title.trim().isEmpty()) {
                        OptionsMenuUtility.fixActionBar(AlbumListingActivity.this,
                                getString(R.string.imgur_album) + ": " + info.title);
                    }

                    layout.removeAllViews();

                    final ListView listView = new ListView(AlbumListingActivity.this);
                    listView.setAdapter(new AlbumAdapter(info));
                    layout.addView(listView);

                    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(final AdapterView<?> parent, final View view,
                                final int position, final long id) {

                            LinkHandler.onLinkClicked(AlbumListingActivity.this,
                                    info.images.get(position).urlOriginal, false, null, info, position);
                        }
                    });
                }
            });
        }
    });

    setContentView(layout);
}