List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
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 w w w. j a v a 2 s .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.example.QQReader.OpenSourceWidget.astuetz.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from w ww . java2 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); 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.dyh.views.TabPageIndicator.java
public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(getContext()); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, FILL_PARENT)); }
From source file:com.astuetz.viewpager.extensions.ScrollingTabsView.java
public ScrollingTabsView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); this.mContext = context; mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop); mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom); mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0); mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor); mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop, mDividerMarginTop);//ww w . ja v a 2 s .c o m mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom, mDividerMarginBottom); mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable); a.recycle(); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); mContainer.setLayoutParams(params); mContainer.setOrientation(LinearLayout.HORIZONTAL); this.addView(mContainer); }
From source file:com.fuse.qreader.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. */// w w w . j a va 2s.c o 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(); } }
From source file:co.ldln.android.ObjectCreateFragment.java
@Override public void onReadSchemaResult(final Schema schema) { mTextFields = new ArrayList<EditText>(); // Create the form based on the schema fields List<SchemaField> fieldList = new ArrayList<SchemaField>(); fieldList.addAll(schema.getFields(mActivity)); Collections.sort(fieldList);/*from ww w . jav a 2 s .c om*/ for (SchemaField field : fieldList) { String type = field.getType(); String label = field.getLabel(); // 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 EditText EditText et = new EditText(mActivity); LayoutParams etParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); et.setLayoutParams(etParams); et.setHint(label); if (type.equals("map_location")) et.setText(mMapLocation); ll.addView(et); mTextFields.add(et); mFormHolder.addView(ll); } // Add submit button Button b = new Button(mActivity); LayoutParams bParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); b.setText("Save"); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { String kvPairs = ""; JSONObject kvPairsJsonObject = new JSONObject(); for (EditText et : mTextFields) { String key = et.getHint().toString(); String value = et.getText().toString(); kvPairsJsonObject.put(key, value); } kvPairs = kvPairsJsonObject.toString(); LDLN.saveSyncableObject(mActivity, ObjectCreateFragment.this, schema.getKey(), kvPairs); } catch (JSONException e) { e.printStackTrace(); onSaveSyncableObjectResult(false); } } }); mFormHolder.addView(b); Toast.makeText(mActivity, "This is a form that's dynamically generated from a syncable object schema. It will soon have handling for dynamic form elements (photo, latlon picker, etc).", Toast.LENGTH_LONG).show(); }
From source file:com.ereader.client.ui.view.TabsView.java
public TabsView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); this.mContext = context; mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop); mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom); mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0); mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor); mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop, mDividerMarginTop);// www . jav a 2 s.c o m mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom, mDividerMarginBottom); mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable); a.recycle(); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mContainer.setLayoutParams(params); mContainer.setOrientation(LinearLayout.HORIZONTAL); mContainer.setGravity(Gravity.CENTER); this.addView(mContainer); }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//w w w.j a v a2s . c o m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:com.chenjishi.u148.view.TabPageIndicator.java
public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(context); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); }
From source file:com.ereader.client.ui.view.ScrollingTabsView.java
public ScrollingTabsView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); this.mContext = context; mDividerMarginTop = (int) (getResources().getDisplayMetrics().density * mDividerMarginTop); mDividerMarginBottom = (int) (getResources().getDisplayMetrics().density * mDividerMarginBottom); mDividerWidth = (int) (getResources().getDisplayMetrics().density * mDividerWidth); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0); mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor); mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop, mDividerMarginTop);//w ww.j ava 2 s. c o m mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom, mDividerMarginBottom); mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable); a.recycle(); this.setHorizontalScrollBarEnabled(false); this.setHorizontalFadingEdgeEnabled(false); mContainer = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mContainer.setLayoutParams(params); mContainer.setOrientation(LinearLayout.HORIZONTAL); mContainer.setGravity(Gravity.CENTER); this.addView(mContainer); }