List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
From source file:id.nci.stm_9.ExpandableListFragment.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.//from w w w .ja v a2 s.co m * * <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. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ 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)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_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)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, 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:org.cafemember.messenger.mytg.fragments.TransfareActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getContext();/* w w w . j av a 2 s .com*/ // View layout = inflater.inflate(R.layout.channels_layout, null); /*this.context = context; actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("MenuTransfare", R.string.MenuTransfare)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { saveName(); }else if (id == contact_button) { getContacts(); } } }); ActionBarMenu menu = actionBar.createMenu(); contactsButton = menu.addItemWithWidth(contact_button, R.drawable.user_profile, AndroidUtilities.dp(56)); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); */ LinearLayout fragmentView = new LinearLayout(context); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TextView ruleTextView = new TextView(context); ruleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); ruleTextView.setTextColor(0xff212121); ruleTextView.setGravity(Gravity.RIGHT); // ruleTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("ShareText", R.string.ShareText))); ruleTextView.setText(LocaleController.getString("transfare_rule", R.string.transfare_rule)); ((LinearLayout) fragmentView).addView(ruleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 24, 10, 24, 30)); phoneField = new EditText(context); phoneField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); phoneField.setHintTextColor(0xff979797); phoneField.setTextColor(0xff212121); phoneField.setMaxLines(1); phoneField.setLines(1); phoneField.setGravity(Gravity.RIGHT); phoneField.setPadding(0, 0, 0, 0); phoneField.setSingleLine(true); phoneField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); phoneField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); phoneField.setImeOptions(EditorInfo.IME_ACTION_DONE); phoneField.setHint(LocaleController.getString("TransfareUserHint", R.string.TransfareUserHint)); AndroidUtilities.clearCursorDrawable(phoneField); amountField = new EditText(context); amountField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); amountField.setHintTextColor(0xff979797); amountField.setTextColor(0xff212121); amountField.setMaxLines(1); amountField.setGravity(Gravity.RIGHT); amountField.setLines(1); amountField.setPadding(0, 0, 0, 0); amountField.setSingleLine(true); amountField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); amountField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); amountField.setImeOptions(EditorInfo.IME_ACTION_DONE); amountField.setHint(LocaleController.getString("TransfareAmountHint", R.string.TransfareAmountHint)); AndroidUtilities.clearCursorDrawable(amountField); phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) { doneButton.performClick(); return true; } return false; } }); ((LinearLayout) fragmentView).addView(phoneField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0)); checkTextView = new TextView(context); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setGravity(Gravity.RIGHT); ((LinearLayout) fragmentView).addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 12, 24, 0)); Button button = new Button(context); button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); button.setTextColor(0xff6d6d72); button.setGravity(Gravity.CENTER); TextView helpTextView = new TextView(context); helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); helpTextView.setTextColor(0xff6d6d72); helpTextView.setGravity(Gravity.RIGHT); helpTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("RefHelp", R.string.RefHelp))); button.setText(""); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveName(); } }); ((LinearLayout) fragmentView).addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 0)); ((LinearLayout) fragmentView).addView(amountField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0)); ((LinearLayout) fragmentView).addView(button, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 24, 24, 0)); /*View v = LayoutInflater.from(context).inflate(R.layout.transfare_type, null); typeJoin = (RadioButton)v.findViewById(R.id.joinRadio); typeView = (RadioButton)v.findViewById(R.id.viewRadio); ((LinearLayout) fragmentView).addView(v, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));*/ phoneField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { checkUserName(phoneField.getText().toString(), false); } @Override public void afterTextChanged(Editable editable) { } }); checkTextView.setVisibility(View.GONE); FontManager.instance().setTypefaceImmediate(fragmentView); return fragmentView; }
From source file:com.example.drugsformarinemammals.Dose_Information.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dose_information); Bundle parameters = this.getIntent().getExtras(); if (parameters != null) { TextView textViewDrug = (TextView) findViewById(R.id.textView_drug_name); textViewDrug.setTypeface(Typeface.SANS_SERIF); textViewDrug.setText(parameters.getString("drugName")); TextView textViewGroupName = (TextView) findViewById(R.id.textView_group_name); textViewGroupName.setTypeface(Typeface.SANS_SERIF); textViewGroupName.setText("(" + parameters.getString("groupName") + ")"); layoutDose = (LinearLayout) findViewById(R.id.layout_dose); helper = new Handler_Sqlite(this); SQLiteDatabase db = helper.open(); ArrayList<String> notes_index = new ArrayList<String>(); ArrayList<String> references = new ArrayList<String>(); ArrayList<Article_Reference> references_index = new ArrayList<Article_Reference>(); reference_index = 'a'; ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(parameters.getString("drugName"), parameters.getString("groupName")); for (int l = 0; l < families.size(); l++) { //if exists animals family TextView textView_family = new TextView(this); textView_family.setText(families.get(l)); textView_family.setTextSize(20); textView_family.setTextColor(getResources().getColor(R.color.darkGray)); textView_family.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 30;/*from ww w . j a v a 2 s. c o m*/ params.topMargin = 20; layoutDose.addView(textView_family, layoutDose.getChildCount(), params); //dose information LinearLayout layout_dose_information = new LinearLayout(this); layout_dose_information.setOrientation(LinearLayout.VERTICAL); layout_dose_information .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); layout_dose_information.setBackgroundResource(R.drawable.layout_border); ArrayList<Dose_Data> dose = new ArrayList<Dose_Data>(); if (db != null) { dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "", ""); } TableLayout doseTable = new TableLayout(this); doseTable.setStretchAllColumns(true); screenWidth = Integer.parseInt(getString(R.string.display)); TableRow header = new TableRow(this); //Amount TextView textView_dose_amount = new TextView(this); textView_dose_amount.setText("Dose"); textView_dose_amount.setSingleLine(true); textView_dose_amount.setTextColor(getResources().getColor(R.color.darkGray)); textView_dose_amount.setTextSize(17); textView_dose_amount.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsAmount.gravity = Gravity.CENTER; header.addView(textView_dose_amount, paramsAmount); //Posology TextView textView_posology = new TextView(this); if (screenWidth >= 720) textView_posology.setText("Posology"); else textView_posology.setText("Pos"); textView_posology.setSingleLine(true); textView_posology.setTextColor(getResources().getColor(R.color.darkGray)); textView_posology.setTextSize(17); textView_posology.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsPosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsPosology.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology")) || screenWidth >= 600) header.addView(textView_posology, paramsPosology); //Route TextView textView_route = new TextView(this); textView_route.setText("Route"); textView_route.setSingleLine(true); textView_route.setTextColor(getResources().getColor(R.color.darkGray)); textView_route.setTextSize(17); textView_route.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsRoute = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsRoute.gravity = Gravity.CENTER; header.addView(textView_route, paramsRoute); //Reference TextView textView_reference = new TextView(this); textView_reference.setText("Ref"); textView_reference.setSingleLine(true); textView_reference.setTextColor(getResources().getColor(R.color.darkGray)); textView_reference.setTextSize(17); textView_reference.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsReference = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsReference.gravity = Gravity.CENTER; header.addView(textView_reference, paramsReference); //Specific Note TextView textView_specific_note = new TextView(this); textView_specific_note.setText("Note"); textView_specific_note.setSingleLine(true); textView_specific_note.setTextColor(getResources().getColor(R.color.darkGray)); textView_specific_note.setTextSize(17); textView_specific_note.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsSpecificNote = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNote.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) || screenWidth >= 600) header.addView(textView_specific_note, paramsSpecificNote); TableRow doseData = new TableRow(this); doseTable.addView(header); //General Dose if (dose.size() > 0) { show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "", "", notes_index, references, references_index); } HashMap<String, ArrayList<String>> animal_information = new HashMap<String, ArrayList<String>>(); if (db != null) animal_information = helper.read_animal_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l)); String animalName; Object[] animalsName = animal_information.keySet().toArray(); for (int i = 0; i < animalsName.length; i++) { doseData = new TableRow(this); //if exists animal name animalName = (String) animalsName[i]; TextView textView_animal_name = new TextView(this); if (!animalName.equals("")) { //Animal name textView_animal_name.setText(animalName); textView_animal_name.setSingleLine(false); textView_animal_name.setTextColor(getResources().getColor(R.color.darkGray)); textView_animal_name.setTextSize(15); textView_animal_name.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); } //if exists category ArrayList<String> categories = animal_information.get(animalName); String animalCategory; for (int j = 0; j < categories.size(); j++) { animalCategory = categories.get(j); if (!animalCategory.equals("")) { //Animal category TextView textView_animal_category = new TextView(this); textView_animal_category.setText(animalCategory); textView_animal_category.setSingleLine(false); textView_animal_category.setTextColor(Color.BLACK); textView_animal_category.setTextSize(15); textView_animal_category.setTypeface(Typeface.SANS_SERIF); if (!animalName.equals("")) { if (j == 0) { TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsAnimalName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsAnimalName.span = 4; else paramsAnimalName.span = 5; doseData.addView(textView_animal_name, paramsAnimalName); doseTable.addView(doseData); } if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); doseData = new TableRow(this); textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC); TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsCategoryName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsCategoryName.span = 4; else paramsCategoryName.span = 5; if (screenWidth < 600) paramsCategoryName.leftMargin = 15; else if (screenWidth >= 600 && screenWidth < 720) paramsCategoryName.leftMargin = 20; else paramsCategoryName.leftMargin = 30; doseData.addView(textView_animal_category, paramsCategoryName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } else { if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); textView_animal_category.setTextColor(getResources().getColor(R.color.darkGray)); TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsCategoryName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsCategoryName.span = 4; else paramsCategoryName.span = 5; doseData.addView(textView_animal_category, paramsCategoryName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } } if (!animalName.equals("") && animalCategory.equals("")) { if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsAnimalName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsAnimalName.span = 4; else paramsAnimalName.span = 5; doseData.addView(textView_animal_name, paramsAnimalName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } } } LinearLayout.LayoutParams paramsDoseTable = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); if (screenWidth >= 600) { paramsDoseTable.topMargin = 5; paramsDoseTable.leftMargin = 50; paramsDoseTable.rightMargin = 50; } else { paramsDoseTable.topMargin = 5; paramsDoseTable.leftMargin = 60; paramsDoseTable.rightMargin = 30; } layout_dose_information.addView(doseTable, paramsDoseTable); layoutDose.addView(layout_dose_information, layoutDose.getChildCount()); } helper.close(); //Notes additionalInformationInterface("GENERAL NOTES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); additionalInformationInterface("SPECIFIC NOTES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); //References additionalInformationInterface("REFERENCES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); } }
From source file:com.tombarrasso.android.app.GridFragment.java
/** * Provide default implementation to return a simple grid view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a GridView 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 grid is empty. * //ww w . ja va 2 s .c o m * <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. */ @SuppressWarnings("deprecation") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ 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.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GridView lv = new GridView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:org.mariotaku.twidere.fragment.support.BasePullToRefreshMultiColumnListFragment.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./*from w w w .ja v a 2 s .co m*/ * <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. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final 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)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final 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)); final PullToRefreshLayout plv = new PullToRefreshLayout(context); mPullToRefreshLayout = plv; final MultiColumnListView lv = createMultiColumnListView(context, inflater); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); plv.addView(lv, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); final Options.Builder builder = new Options.Builder(); builder.scrollDistance(DEFAULT_PULL_TO_REFRESH_SCROLL_DISTANCE); builder.headerTransformer(new TwidereHeaderTransformer()); if (!isDetached() && getActivity() != null) { final SetupWizard wizard = ActionBarPullToRefresh.from(getActivity()); wizard.allChildrenArePullable(); wizard.useViewDelegate(MultiColumnListView.class, new PLAAbsListViewDelegate()); wizard.listener(this); wizard.options(builder.build()); wizard.setup(mPullToRefreshLayout); } // ViewCompat.setOverScrollMode(lv, ViewCompat.OVER_SCROLL_NEVER); lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, 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:org.mariotaku.twidere.fragment.BasePullToRefreshListFragment.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.//w w w . j av a 2s . c om * * <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. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new HoloProgressBar(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)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final 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)); final PullToRefreshListView plv = new PullToRefreshListView(context); plv.setOnRefreshListener(this); plv.setShowIndicator(false); plv.setOnPullEventListener(new AccessibilityPullEventListener<ListView>(context)); plv.setPullToRefreshOverScrollEnabled(false); mPullToRefreshListView = plv; final ListView lv = plv.getRefreshableView(); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); // ViewCompat.setOverScrollMode(lv, ViewCompat.OVER_SCROLL_NEVER); lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, 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.murrayc.galaxyzoo.app.QuestionHelpFragment.java
private void addRowForAnswer(final Context context, final TableLayout tableLayout, final DecisionTree.Question question, final DecisionTree.BaseButton answer) { final TableRow row = new TableRow(context); final TableLayout.LayoutParams params = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); params.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin), 0, 0); tableLayout.addView(row, params);//from w w w . j av a 2 s. c om final LinearLayout layoutVertical = new LinearLayout(context); layoutVertical.setOrientation(LinearLayout.VERTICAL); final TextView textViewAnswer = new AppCompatTextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textViewAnswer.setTextAppearance(R.style.TextAppearance_AppCompat_Subhead); } else { //noinspection deprecation textViewAnswer.setTextAppearance(context, R.style.TextAppearance_AppCompat_Subhead); } textViewAnswer.setText(answer.getText()); layoutVertical.addView(textViewAnswer, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final LinearLayout layoutHorizontal = new LinearLayout(context); layoutHorizontal.setOrientation(LinearLayout.HORIZONTAL); final LinearLayout.LayoutParams paramsHorizontal = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); paramsHorizontal.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_margin), 0, 0); layoutVertical.addView(layoutHorizontal, paramsHorizontal); final BitmapDrawable icon = getIcon(context, answer); final ImageView imageIcon = new ImageView(context); imageIcon.setImageDrawable(icon); layoutHorizontal.addView(imageIcon); final LinearLayout.LayoutParams paramsImage = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); // TODO: Use a custom FlowTable class to avoid items going off the right edge of the screen // when there are too many. final Singleton singleton = getSingleton(); for (int i = 0; i < answer.getExamplesCount(); i++) { final String iconName = answer.getExampleIconName(question.getId(), i); final BitmapDrawable iconExample = singleton.getIconDrawable(context, iconName); final ImageButton imageExample = new ImageButton(context); //Remove the space between the image and the outside of the button: imageExample.setPadding(0, 0, 0, 0); imageExample.setImageDrawable(iconExample); //Needed to make the image expand as a transition into the SubjectViewerActivity, //which uses the same name in fragment_subject.xml ViewCompat.setTransitionName(imageExample, getString(R.string.transition_subject_image)); //This requires API level 17: paramsImage.setMarginStart(getPxForDp(activity, MARGIN_MEDIUM_DP)); //imageExample.setLayoutParams(paramsImage); MarginLayoutParamsCompat.setMarginStart(paramsImage, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin)); final int answerIndex = i; imageExample.setOnClickListener(new View.OnClickListener() { public void onClick(final View v) { // Perform action on click onExampleImageClicked(v, answer, answerIndex); } }); layoutHorizontal.addView(imageExample, paramsImage); } row.addView(layoutVertical, new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); }
From source file:at.wada811.app.fragment.ExpandableListFragment.java
/** * Provide default implementation to return a expandable list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ExpandableListView 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.//from w w w . j av a 2 s.c o m * * <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 ExpandableListFragment. In particular, * this is currently the only way to have the built-in indeterminant progress state be shown. * * @param inflater The LayoutInflater object that can be used to inflate any views in the * fragment, * @param container If non-null, this is the parent view that the fragment's UI should be * attached to. The fragment should not add the view itself, but this can be used to * generate the LayoutParams of the view. * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous * saved state as given here. * @return Return the View for the fragment's UI, or null. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final 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)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final 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)); final ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, 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.tiancaicc.springfloatingactionmenu.MenuItemView.java
private void init(Context context, boolean hasMargin) { Resources resources = getResources(); int diameterPX = Utils.dpToPx(mMenuItem.getDiameter(), resources); this.mDiameter = diameterPX; mBtn = new ImageButton(context); mBtn.setScaleType(ImageView.ScaleType.FIT_CENTER); if (hasMargin) { int p = Util.dpToPx(12, getResources()); mBtn.setPadding(p, p, p, p);//from w w w .j av a 2 s. c o m } LayoutParams btnLp = new LayoutParams(diameterPX, diameterPX); btnLp.gravity = Gravity.CENTER_HORIZONTAL; btnLp.bottomMargin = Util.dpToPx(mGapSize, resources); mBtn.setLayoutParams(btnLp); OvalShape ovalShape = new OvalShape(); ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape); shapeDrawable.getPaint().setColor(resources.getColor(mMenuItem.getBgColor())); mBtn.setBackgroundDrawable(shapeDrawable); if (TextUtils.isEmpty(mMenuItem.getIconFilePath())) { mBtn.setImageResource(mMenuItem.getIcon()); } else { mBtn.setImageURI(Uri.fromFile(new File(mMenuItem.getIconFilePath()))); } mBtn.setClickable(false); addView(mBtn); mLabel = (com.github.omadahealth.typefaceview.TypefaceTextView) View.inflate(getContext(), R.layout.c_text_view, null); mLabel.setPaintFlags(mLabel.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); mLabel.setTextIsSelectable(false); LayoutParams labelLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); labelLp.gravity = Gravity.CENTER_HORIZONTAL; mLabel.setLayoutParams(labelLp); if (!TextUtils.isEmpty(mMenuItem.getLabel())) { mLabel.setPadding(0, Util.dpToPx(70, getResources()), 0, 0); Drawable bottomArrow = ContextCompat.getDrawable(getContext(), R.drawable.ic_arrow); mLabel.setCompoundDrawablesWithIntrinsicBounds(null, null, null, bottomArrow); } mLabel.setText(mMenuItem.getLabel()); mLabel.setTextColor(resources.getColor(mMenuItem.getTextColor())); // mLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize); addView(mLabel); setOrientation(LinearLayout.VERTICAL); if (mAlphaAnimation) { setAlpha(0); } getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { getViewTreeObserver().removeGlobalOnLayoutListener(this); applyPressAnimation(); ViewGroup parent = (ViewGroup) getParent(); parent.setClipChildren(false); parent.setClipToPadding(false); setClipChildren(false); setClipToPadding(false); } }); }
From source file:cn.org.eshow.framwork.view.sliding.AbBottomTabView.java
/** * Instantiates a new ab bottom tab view. * * @param context the context/*from w ww . j a va 2 s .c o m*/ * @param attrs the attrs */ public AbBottomTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new AbViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); //? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }