Example usage for android.widget LinearLayout HORIZONTAL

List of usage examples for android.widget LinearLayout HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Usage

From source file:de.grobox.liberario.ui.TimeAndDateView.java

public TimeAndDateView(Context context, AttributeSet attr) {
    super(context, attr);

    setOrientation(LinearLayout.HORIZONTAL);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.time_and_date, this, true);
    ui = new TimeAndDateViewHolder(this);

    // Initialize current Time and Date, display it in UI
    reset();//ww w . j  av a  2s. c om

    // Time
    ui.time.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TimePickerFragment newFragment = new TimePickerFragment();
            newFragment.setOnTimeSetListener(TimeAndDateView.this);
            // show current time also in dialog if time set to now
            if (now)
                resetTime();
            Bundle bundle = new Bundle();
            bundle.putSerializable(DATE, calendar);
            newFragment.setArguments(bundle);
            newFragment.show(((FragmentActivity) getContext()).getSupportFragmentManager(), "timePicker");

        }
    });
    // set current time on long click
    ui.time.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            resetTime();
            Toast.makeText(getContext(), R.string.current_time_set, LENGTH_SHORT).show();
            return true;
        }
    });

    // Date
    ui.date.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DatePickerFragment newFragment = new DatePickerFragment();
            newFragment.setOnDateSetListener(TimeAndDateView.this);
            // show current date also in dialog if set to today
            if (today)
                resetDate();
            Bundle bundle = new Bundle();
            bundle.putSerializable(DATE, calendar);
            newFragment.setArguments(bundle);
            newFragment.show(((FragmentActivity) getContext()).getSupportFragmentManager(), "datePicker");
        }
    });
    // set current date on long click
    ui.date.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            resetDate();
            Toast.makeText(getContext(), R.string.current_date_set, LENGTH_SHORT).show();
            return true;
        }
    });

    // Plus 15
    ui.plus15.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            addTime(15);
        }
    });
    // plus 1 hour on long click
    ui.plus15.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            addTime(60);
            Toast.makeText(getContext(), R.string.added_1h, LENGTH_SHORT).show();
            return true;
        }
    });
}

From source file:de.mkrtchyan.recoverytools.DonationsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Layout = new LinearLayout(this);
    Layout.setHorizontalGravity(LinearLayout.HORIZONTAL);
    Layout.setId(1111111);/*from  w  w  w.j ava  2 s.com*/

    setContentView(Layout);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    DonationsFragment donationsFragment;
    donationsFragment = DonationsFragment.newInstance(BuildConfig.DEBUG, GOOGLE_PLAY, GOOGLE_PUBKEY,
            GOOGLE_CATALOG, getResources().getStringArray(R.array.donation_google_catalog_values), PAYPAL,
            PAYPAL_USER, PAYPAL_CURRENCY_CODE, PAYPAL_ITEM_NAME, FLATTR, FLATTR_PROJECT_URL, FLATTR_URL);

    ft.replace(Layout.getId(), donationsFragment, "donationsFragment");
    ft.commit();
}

From source file:com.b44t.ui.Components.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context) {
    super(context);

    setFillViewport(true);/*from  w w w  .  ja va  2  s .c om*/
    setWillNotDraw(false);

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

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

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT);
}

From source file:de.mdxdave.materialbreadcrumbsnavigation.MaterialBreadcrumbsNavigation.java

public MaterialBreadcrumbsNavigation(Context context, AttributeSet attrs) {
    super(context, attrs);

    this.context = context;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialBreadcrumbsNavigation, 0, 0);
    textColor = a.getColor(R.styleable.MaterialBreadcrumbsNavigation_textColor,
            ContextCompat.getColor(context, R.color.default_text));
    indicatorColor = a.getColor(R.styleable.MaterialBreadcrumbsNavigation_arrowColor,
            ContextCompat.getColor(context, R.color.default_indicator));
    backgroundColor = a.getColor(R.styleable.MaterialBreadcrumbsNavigation_backgroundColor,
            ContextCompat.getColor(context, R.color.default_background));
    a.recycle();/*  ww  w  .  j  a v a  2s.  c  o  m*/

    setOrientation(LinearLayout.HORIZONTAL);
    setGravity(Gravity.CENTER_VERTICAL);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.main_view, this, true);
    horizontalScrollView = (HorizontalScrollView) view.findViewById(R.id.horizontalScrollView);
    horizontalScrollView.setBackgroundColor(backgroundColor);
    viewGroup = (ViewGroup) findViewById(R.id.parent_view);

    list = new ArrayList<>();
}

From source file:co.ldln.android.ObjectReadFragment.java

@Override
public void onReadSchemaResult(Schema schema) {
    mSchema = schema;/* w  w  w.  j a v a 2 s .  co  m*/
    HashMap<String, String> keyValueMap = mSyncableObject.getKeyValueMap();
    for (SchemaField schemaField : mSchema.getFields(mActivity)) {
        String label = schemaField.getLabel();
        String value = keyValueMap.get(label);
        String type = schemaField.getType();

        // Create a linear layout to hold the field
        LinearLayout ll = new LinearLayout(mActivity);
        LayoutParams llParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        ll.setLayoutParams(llParams);
        ll.setOrientation(LinearLayout.HORIZONTAL);

        // TODO: different UI for different field types

        // Default to TextView
        TextView labelTv = new TextView(mActivity);
        LayoutParams labelTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        labelTv.setLayoutParams(labelTvParams);
        labelTv.setText(label);
        labelTv.setPadding(0, 0, 20, 0);
        labelTv.setTypeface(Typeface.DEFAULT_BOLD);
        ll.addView(labelTv);

        TextView valueTv = new TextView(mActivity);
        LayoutParams valueTvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        valueTv.setLayoutParams(valueTvParams);
        valueTv.setText(value);
        ll.addView(valueTv);

        mFormHolder.addView(ll);
    }
}

From source file:com.codeslap.topy.BaseMultiPaneActivity.java

public View getTwoColumns(Fragment firstFragment, float firstWeight, Fragment secondFragment,
        float secondWeight) {
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    int firstId = 1;
    int secondId = 2;

    FrameLayout firstLayout = new FrameLayout(this);
    LinearLayout.LayoutParams firstParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.FILL_PARENT);
    firstParams.weight = firstWeight;// w w  w .j  av  a  2  s .c  o  m
    firstLayout.setLayoutParams(firstParams);
    firstLayout.setId(firstId);

    FrameLayout secondLayout = new FrameLayout(this);
    LinearLayout.LayoutParams secondParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.FILL_PARENT);
    secondLayout.setLayoutParams(secondParams);
    secondParams.weight = secondWeight;
    secondLayout.setId(secondId);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(firstId, firstFragment);
    ft.add(2, secondFragment);
    ft.commit();

    linearLayout.addView(firstLayout);
    linearLayout.addView(secondLayout);

    return linearLayout;
}

From source file:com.mishiranu.dashchan.content.service.AudioPlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = new ContextThemeWrapper(this, Preferences.getThemeResource());
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    float density = ResourceUtils.obtainDensity(this);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding_view);
    linearLayout.setPadding(padding, padding, padding, C.API_LOLLIPOP ? (int) (8f * density) : padding);
    textView = new TextView(context, null, android.R.attr.textAppearanceListItem);
    linearLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    textView.setPadding(0, 0, 0, 0);/* ww  w.ja v  a2s .c o  m*/
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setSingleLine(true);
    LinearLayout horizontal = new LinearLayout(context);
    horizontal.setOrientation(LinearLayout.HORIZONTAL);
    horizontal.setGravity(Gravity.CENTER_VERTICAL);
    horizontal.setPadding(0, (int) (16f * density), 0, 0);
    linearLayout.addView(horizontal, LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    seekBar = new SeekBar(context);
    horizontal.addView(seekBar, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    seekBar.setPadding((int) (8f * density), 0, (int) (16f * density), 0);
    seekBar.setOnSeekBarChangeListener(this);
    button = new ImageButton(context);
    horizontal.addView(button, (int) (48f * density), (int) (48f * density));
    button.setBackgroundResource(
            ResourceUtils.getResourceId(context, android.R.attr.listChoiceBackgroundIndicator, 0));
    setPlayState(false);
    button.setOnClickListener(this);
    alertDialog = new AlertDialog.Builder(context).setView(linearLayout).setOnCancelListener(this)
            .setPositiveButton(R.string.action_stop, this).show();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(AudioPlayerService.ACTION_TOGGLE);
    intentFilter.addAction(AudioPlayerService.ACTION_CANCEL);
    LocalBroadcastManager.getInstance(this).registerReceiver(audioPlayerReceiver, intentFilter);
    bindService(new Intent(this, AudioPlayerService.class), this, 0);
}

From source file:com.negaheno.ui.Components.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*from   ww w  .ja  v  a 2  s . c  om*/
    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);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

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

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);

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

From source file:com.example.QQReader.OpenSourceWidget.astuetz.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {

    super(context, attrs, defStyle);

    setFillViewport(true);// w  ww .jav  a 2 s.c  o  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);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

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

    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.wunding.mlplayer.ui.PagerSlidingTabStrip.java

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

    setFillViewport(true);// w w  w.j  a  v a2s  .c  o  m
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    pageListener = new PageListener();

    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);
    indicatorHeight = getContext().getResources().getDimensionPixelOffset(R.dimen.tab_buttom);
    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    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;
    }
}