List of usage examples for android.widget LinearLayout setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:eu.power_switch.gui.fragment.configure_scene.ConfigureSceneDialogPage1NameFragment.java
private void addReceiversToLayout() { String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString); try {/* ww w. ja v a2 s.c om*/ for (Room room : DatabaseHandler.getRooms(SmartphonePreferencesHandler.getCurrentApartmentId())) { LinearLayout roomLayout = new LinearLayout(getActivity()); roomLayout.setOrientation(LinearLayout.VERTICAL); roomLayout.setPadding(0, 8, 0, 8); linearLayout_selectableReceivers.addView(roomLayout); TextView roomName = new TextView(getActivity()); roomName.setText(room.getName()); roomName.setTextColor( ThemeHelper.getThemeAttrColor(getActivity(), android.R.attr.textColorPrimary)); roomLayout.addView(roomName); for (Receiver receiver : room.getReceivers()) { LinearLayout receiverLayout = new LinearLayout(getActivity()); receiverLayout.setOrientation(LinearLayout.HORIZONTAL); roomLayout.addView(receiverLayout); final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.simple_checkbox, receiverLayout, false); checkBox.setTag(R.string.room, room); checkBox.setTag(R.string.receiver, receiver); receiverLayout.addView(checkBox); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkValidity(); } }); receiverCheckboxList.add(checkBox); TextView textView_receiverName = new TextView(getActivity()); textView_receiverName.setText(receiver.getName()); receiverLayout.addView(textView_receiverName); receiverLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkBox.setChecked(!checkBox.isChecked()); } }); } } } catch (Exception e) { StatusMessageHandler.showErrorMessage(getActivity(), e); } }
From source file:com.kunalkene1797.blackboxkit.fragments.tools.BuildpropFragment.java
private void addKeyDialog(final String key, final String value, final boolean modify) { LinearLayout dialogLayout = new LinearLayout(getActivity()); dialogLayout.setOrientation(LinearLayout.VERTICAL); dialogLayout.setGravity(Gravity.CENTER); dialogLayout.setPadding(30, 20, 30, 20); final AppCompatEditText keyEdit = new AppCompatEditText(getActivity()); keyEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify)//www . jav a 2 s . c o m keyEdit.setText(key.trim()); else keyEdit.setHint(getString(R.string.key)); final AppCompatEditText valueEdit = new AppCompatEditText(getActivity()); valueEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify) valueEdit.setText(value.trim()); else valueEdit.setHint(getString(R.string.value)); dialogLayout.addView(keyEdit); dialogLayout.addView(valueEdit); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(dialogLayout) .setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (modify) overwrite(key.trim(), value.trim(), keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); else add(keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); } }).show(); }
From source file:com.krg.ParallaxScrollView.sample.PagerViewBackgroundActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create ParallaxScrollView, which will eventually be the container for everything. ParallaxScrollView parallaxScrollView = new ParallaxScrollView(this); parallaxScrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // Create the Background View, a ViewPager. ViewPager backgroundViewPager = new ViewPager(this); backgroundViewPager.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)); ImageAdapter adapter = new ImageAdapter(this); backgroundViewPager.setAdapter(adapter); // Create the Contents View. LinearLayout contentView = new LinearLayout(this); contentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); contentView.setBackgroundColor(0xffffffff); int padding = getResources().getDimensionPixelSize(R.dimen.content_padding); contentView.setPadding(padding, padding, padding, padding); TextView textView = new TextView(this); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setText(R.string.starry_night); float textSize = getResources().getDimension(R.dimen.content_text_size); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); contentView.addView(textView);/* ww w. ja v a2 s .co m*/ // Make the ParallaxScrollView aware of the Background, Content, and Header Views, and set the content of // this view to the ParallaxScrollView. parallaxScrollView.setBackgroundView(backgroundViewPager); parallaxScrollView.setContentView(contentView); setContentView(parallaxScrollView); }
From source file:de.gebatzens.ggvertretungsplan.fragment.ExamFragment.java
@Override public void createView(LayoutInflater inflater, ViewGroup view) { ScrollView sv = new ScrollView(getActivity()); sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); sv.setTag("exam_scroll"); ((LinearLayout) view.findViewById(R.id.exam_content)).addView(sv); LinearLayout l = new LinearLayout(getActivity()); l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); int p = toPixels(6); l.setPadding(p, p, p, p); sv.addView(l);// w ww . ja v a 2s.com createTextView(getResources().getString(R.string.my_exams), toPixels(12), inflater, l); for (Exams.ExamItem item : GGApp.GG_APP.exams) { if (GGApp.GG_APP.filters.mainFilter.matches(item)) { CardView cv = createCardItem(item, inflater); if (cv != null) { l.addView(cv); } } } createTextView(getResources().getString(R.string.all_exams), toPixels(12), inflater, l); for (Exams.ExamItem item : GGApp.GG_APP.exams) { CardView cv = createCardItem(item, inflater); if (cv != null) { l.addView(cv); } } cardColorIndex = 0; }
From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java
/** * Crea un layout verticale utilizzando il solo fragment di sinistra (la lista) *//* w w w .jav a 2s . co m*/ @SuppressWarnings("all") protected View makeLeftPortraitLayout(LayoutInflater inflater) { if (getLayoutResourceId() > 0) { View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null); View rightFragment = v.findViewById(getRightFragmentId()); if (rightFragment != null) { rightFragment.setVisibility(View.GONE); } mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT; return v; } else { LinearLayout layout = new LinearLayout(this); layout.setPadding(10, 10, 10, 10); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setOrientation(LinearLayout.VERTICAL); FrameLayout leftFrame = new FrameLayout(this); leftFrame.setId(getLeftFragmentId()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); leftFrame.setLayoutParams(lp); layout.addView(leftFrame); mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT; return layout; } }
From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java
/** * Crea un layout in landscape utilizzando due fragment di peso proporzionale * Per cambiare le dimensioni dei pesi effettuare l'override dei * metodi <code>getLeftFragmentSize</code> e <code>getRightFragmentSize</code> */// w ww. ja va2s . c o m @SuppressWarnings("all") protected View makeLandscapeLayout(LayoutInflater inflater) { if (getLayoutResourceId() > 0) { View v = inflater.inflate(getLayoutResourceId(), null); mVisualizationMode = VisualizationMode.LANDSCAPE; return v; } else { LinearLayout layout = new LinearLayout(this); layout.setPadding(10, 10, 10, 10); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setOrientation(LinearLayout.HORIZONTAL); FrameLayout leftFrame = new FrameLayout(this); leftFrame.setId(getLeftFragmentId()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, getLeftFragmentWeigth()); leftFrame.setLayoutParams(lp); FrameLayout rightFrame = new FrameLayout(this); rightFrame.setId(getRightFragmentId()); lp = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, getRightFragmentWeigth()); rightFrame.setLayoutParams(lp); layout.addView(leftFrame); layout.addView(rightFrame); mVisualizationMode = VisualizationMode.LANDSCAPE; return layout; } }
From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java
/** * Crea un layout verticale utilizzando il solo fragment di destra (il dettaglio) *//*from ww w.j a v a2s . c o m*/ @SuppressWarnings("all") protected View makeRightPortraitLayout(LayoutInflater inflater) { if (getLayoutResourceId() > 0) { View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null); View leftFragment = v.findViewById(getLeftFragmentId()); if (leftFragment != null) { leftFragment.setVisibility(View.GONE); } mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT; // getActionBar().setDisplayHomeAsUpEnabled(true); return v; } else { LinearLayout layout = new LinearLayout(this); layout.setPadding(10, 10, 10, 10); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setOrientation(LinearLayout.VERTICAL); FrameLayout rightFrame = new FrameLayout(this); rightFrame.setId(getRightFragmentId()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); rightFrame.setLayoutParams(lp); layout.addView(rightFrame); mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT; // getActionBar().setDisplayHomeAsUpEnabled(true); return layout; } }
From source file:pl.bcichecki.rms.client.android.dialogs.RemindPasswordDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { context = getActivity();/*w w w .j av a2 s .c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.dialog_remind_password_title)); builder.setMessage(getString(R.string.dialog_remind_password_message)); final LinearLayout layout = new LinearLayout(getActivity()); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER_HORIZONTAL); int space = (int) AppUtils.convertDpToPixel(getActivity(), 16); layout.setPadding(space, 0, space, 0); final EditText usernameEditText = new EditText(getActivity()); usernameEditText.setHint(getString(R.string.dialog_remind_password_enter_username_hint)); usernameEditText.setMaxLines(1); usernameEditText.setSingleLine(); usernameEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); usernameEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { usernameEditText.setError(null); } }); layout.addView(usernameEditText); builder.setView(layout); builder.setPositiveButton(getString(R.string.dialog_remind_password_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { return; } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }); builder.setCancelable(false); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { utilitiesRestClient = new UtilitiesRestClient(getActivity(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!AppUtils.checkInternetConnection(getActivity())) { Log.d(TAG, "There is NO network connected!"); return; } usernameEditText.setError(null); if (StringUtils.isBlank(usernameEditText.getText().toString())) { usernameEditText.setError(getString(R.string.dialog_remind_password_field_required)); return; } final String username = usernameEditText.getText().toString(); utilitiesRestClient.forgotPassword(username, new AsyncHttpResponseHandler() { @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Reminding password failed. [error=" + error + ", content=" + content + "]"); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_failed), Toast.LENGTH_LONG); } @Override public void onFinish() { positiveButton.setEnabled(true); } @Override public void onStart() { Log.d(TAG, "Reminding password for user: " + username); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_in_progress), Toast.LENGTH_SHORT); positiveButton.setEnabled(false); } @Override public void onSuccess(int statusCode, String content) { Log.d(TAG, "Reminding password success."); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_successful), Toast.LENGTH_SHORT); dialog.dismiss(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelRequests(); dialog.dismiss(); } }); } }); return dialog; }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Active_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1); ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams(/*from ww w . j av a2 s . c o m*/ new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); //////////////////////////////////////// return ActivateColorize(ll, text, dr); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout make_Inactive_Tab(String text, Drawable dr) { LinearLayout ll = new LinearLayout(this); ll.setPadding(0, 0, 2, 1); ll.setBackgroundColor(Color.GRAY); ll.setTag("ll"); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams(/*from ww w. j ava2s . co m*/ new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1)); //------ Text TextView tv = new TextView(this); tv.setBackgroundColor(Color.TRANSPARENT); tv.setTag("tv"); ll.addView(tv); // ------ hbar View hbar = new View(this); hbar.setTag("hbar"); hbar.setLayoutParams( new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10)); ll.addView(hbar); ///////////////////////////////////// return InActivateColorize(ll, text, dr); }