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:illab.nabal.proxy.AuthWebDialog.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // prepare web view layout
    mLayout = new LinearLayout(getContext());
    mLayout.setOrientation(LinearLayout.VERTICAL);

    // set up title bar
    setUpTitle();//from  w w w .  j  a  v a  2s.  com

    // set up web view
    setUpWebView();

    // determine screen width and height
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindow().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenWidth = displaymetrics.widthPixels;
    int screenHeight = displaymetrics.heightPixels;

    // add layout to screen
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams((int) (screenWidth * 0.90),
            (int) (screenHeight * 0.90));
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(mLayout, layoutParams);
}

From source file:br.org.funcate.dynamicforms.views.GDateView.java

/**
 * @param fragment   the fragment to use.
 * @param attrs attributes./*from ww  w  .j a  v a2  s .c  o m*/
 * @param parentView parent
 * @param label label
 * @param value value
 * @param constraintDescription constraints
 * @param readonly if <code>false</code>, the item is disabled for editing.
 */
public GDateView(final Fragment fragment, AttributeSet attrs, LinearLayout parentView, String label,
        String value, String constraintDescription, boolean readonly) {
    super(fragment.getActivity(), attrs);

    final Context context = fragment.getActivity();

    LinearLayout textLayout = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(context);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(context.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    button = new Button(context);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);

    final SimpleDateFormat dateFormatter = TimeUtilities.INSTANCE.DATEONLY_FORMATTER;
    if (value == null || value.length() == 0) {
        String dateStr = dateFormatter.format(new Date());
        button.setText(dateStr);
    } else {
        button.setText(value);
    }
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String dateStr = button.getText().toString();
            Date date = null;
            try {
                date = dateFormatter.parse(dateStr);
            } catch (ParseException e) {
                //GPLog.error(this, null, e);
                Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
                date = new Date();
            }
            final Calendar c = Calendar.getInstance();
            c.setTime(date);
            int year = c.get(Calendar.YEAR);
            int month = c.get(Calendar.MONTH);
            int day = c.get(Calendar.DAY_OF_MONTH);

            FormDatePickerFragment newFragment = new FormDatePickerFragment();
            newFragment.setAttributes(year, month, day, button);
            newFragment.show(fragment.getFragmentManager(), "datePicker");
        }
    });
    button.setEnabled(!readonly);

    textLayout.addView(button);
}

From source file:com.geecko.QuickLyric.AboutActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
            R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green,
            R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark };
    int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));
    boolean nightMode = sharedPref.getBoolean("pref_night_mode", false);
    if (nightMode && NightTimeVerifier.check(this))
        setTheme(R.style.Theme_QuickLyric_Night);
    else/*  www.j a  v  a  2  s  . c  om*/
        setTheme(themes[themeNum]);
    TypedValue primaryColor = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true);
    setStatusBarColor(null);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    Toolbar toolbar = new Toolbar(this);
    toolbar.setTitle(R.string.pref_about);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        toolbar.setElevation(8f);
    toolbar.setBackgroundColor(primaryColor.data);
    toolbar.setTitleTextColor(Color.WHITE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null,
                primaryColor.data);
        this.setTaskDescription(taskDescription);
    }

    View.OnClickListener productTourAction = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setupDemoScreen();
        }
    };

    Element productTourElement = new Element().setTitle(getString(R.string.about_product_tour));
    productTourElement.setOnClickListener(productTourAction);
    Element crowdinElement = new Element().setTitle(getString(R.string.about_crowdin));
    crowdinElement
            .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/project/quicklyric")));
    Element ossLicensesElement = new Element().setTitle("Open Source Licenses");
    ossLicensesElement.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            WebView webView = new WebView(AboutActivity.this);
            String data = getResources().getString(R.string.open_source_librairies_licenses);
            webView.loadData(data, "text/html; charset=utf-8", "UTF-8");
            new AlertDialog.Builder(AboutActivity.this).setView(webView).show();
        }
    });
    Element tosElement = new Element().setTitle(getString(R.string.about_read_ToS));
    tosElement.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            WebView webView = new WebView(AboutActivity.this);
            String data = getResources().getString(R.string.QL_EULA);
            webView.loadData(data, "text/html; charset=utf-8", "UTF-8");
            new AlertDialog.Builder(AboutActivity.this).setView(webView).show();
        }
    });
    Element cookElement = new Element().setTitle("Icon Designer");
    cookElement.setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("https://cookicons.co/")));

    View aboutView = new AboutPage(this).setDescription("QuickLyric is made with love in Brussels, Belgium.") // FixMe
            .addEmail("contact@QuickLyric.be").addFacebook("QuickLyric").addGitHub("geecko86/QuickLyric")
            .addPlayStore("test").addTwitter("QuickLyric").addWebsite("http://www.quicklyric.be")
            .setImage(R.drawable.icon).addItem(productTourElement).addItem(crowdinElement).addItem(cookElement)
            .addItem(ossLicensesElement).addItem(tosElement).create();
    aboutView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    linearLayout.addView(toolbar);
    linearLayout.addView(aboutView);
    setContentView(linearLayout);

    final Drawable upArrow;
    if (Build.VERSION.SDK_INT >= 21) {
        upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material);
        upArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    } else
        upArrow = getResources().getDrawable(R.drawable.ic_arrow_back);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(upArrow);
}

From source file:org.nuxeo.android.layout.LayoutDefinition.java

protected ViewGroup createTopLayoutContainer(Context ctx, ViewGroup parent) {
    LinearLayout container = new LinearLayout(ctx);
    container.setOrientation(LinearLayout.VERTICAL);
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    container.setLayoutParams(params);/*  w w  w. ja  v  a2s .co  m*/
    parent.addView(container);
    return container;
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * MainLayout
 * @return
 */
protected LinearLayout buildMainContainerLayout() {
    return createMainContainerLayout(LinearLayout.VERTICAL);
}

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

@Override
public void refresh() {
    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);
        // Check if at least a topic is subscribed for this sender
        int subscribedTopics = 0;
        for (Boolean subscribed : sender.topics.values()) {
            if (subscribed) {
                subscribedTopics++;//from   ww w .j a  v a2s  . c o m
            }
        }
        if (subscribedTopics > 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 (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) {
                if (topic.getValue()) {
                    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.bigtop_updates_grey600);
                    label.setText(topic.getKey());
                    button.setText(R.string.topics_unsubscribe);
                    button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE);
                    button.setTag(R.id.tag_senderid, sender.senderId);
                    button.setTag(R.id.tag_topic, topic.getKey());
                    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.topics_no_topic_subscribed));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper);
    topicsView.removeAllViews();
    topicsView.addView(sendersList);
}

From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    // Create the "Step N of T" TextView
    TextView stepTextView = new TextView(this.context);
    stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    stepTextView.setTextColor(Color.rgb(113, 113, 113));
    stepTextView.setGravity(Gravity.CENTER);
    stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1,
            this.solution.size()));

    // Create the boar with the current step of the solution
    BoardCanvas board = new BoardCanvas(this.context);
    board.setBoardRepresentation(this.solution.get(position).getBoard());
    board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(),
            this.solution.get(position).getDirection());

    // Add the components to the layout
    LinearLayout layout = new LinearLayout(this.context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(16, 20, 16, 16);//from   ww  w  .j  a  v  a2  s . c o m

    RelativeLayout relativeLatout = new RelativeLayout(this.context);
    relativeLatout.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    relativeLatout.addView(board);

    layout.addView(relativeLatout);
    layout.addView(stepTextView);
    ((ViewPager) collection).addView(layout, 0);
    return layout;
}

From source file:com.frublin.androidoauth2.FsDialog.java

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

    mContent = new LinearLayout(getContext());
    mContent.setOrientation(LinearLayout.VERTICAL);
    setUpTitle();/*from www. ja v a2s . c o  m*/
    setUpWebView();
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    final float scale = getContext().getResources().getDisplayMetrics().density;
    float[] dimensions = (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT
            : DIMENSIONS_LANDSCAPE;
    addContentView(mContent, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
            (int) (dimensions[1] * scale + 0.5f)));
}

From source file:com.kaedea.frontia.demo.DemoListFragment.java

@SuppressWarnings("ResourceType")
public static View getItemViewLayout(Context context) {
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER_VERTICAL);
    int[] attrs = new int[] { R.attr.selectableItemBackground };
    TypedArray typedArray = context.obtainStyledAttributes(attrs);
    int backgroundResource = typedArray.getResourceId(0, 0);
    linearLayout.setBackgroundResource(backgroundResource);
    typedArray.recycle();//w ww.j  a  va 2  s.c  o  m
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    // Title
    TextView tvTitle = new TextView(context);
    tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16f);
    tvTitle.setMaxLines(1);
    tvTitle.setTextColor(Color.parseColor("#212121"));
    tvTitle.setId(ID_TITLE);
    layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(Utils.dpToPx(context, 20f), Utils.dpToPx(context, 10f), Utils.dpToPx(context, 20f),
            0);
    linearLayout.addView(tvTitle, layoutParams);
    // Sub Title
    TextView tvSubTitle = new TextView(context);
    tvSubTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f);
    tvSubTitle.setMaxLines(2);
    tvSubTitle.setTextColor(Color.parseColor("#757575"));
    tvSubTitle.setId(ID_SUBTITLE);
    layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(Utils.dpToPx(context, 20f), 0, Utils.dpToPx(context, 20f),
            Utils.dpToPx(context, 10f));
    linearLayout.addView(tvSubTitle, layoutParams);
    return linearLayout;
}

From source file:com.fuse.qreader.BarcodeCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *///w  w w .  j a v  a  2 s .  co m
@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    LinearLayout linLayout = new LinearLayout(this);
    linLayout.setOrientation(LinearLayout.VERTICAL);
    LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mPreview = new CameraSourcePreview(this);
    mGraphicOverlay = new GraphicOverlay<BarcodeGraphic>(this);
    mPreview.addView(mGraphicOverlay);
    linLayout.addView(mPreview);

    setContentView(linLayout, linLayoutParam);

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(true);
    } else {
        requestCameraPermission();
    }

}