Center text in div?

To center horizontally, use text-align:center. To center vertically, one can only use vertical-align:middle if there is another element in the same row that it is being aligned to. See it working here. We use an empty span with a height of 100%, and then put the content in the next element with a vertical-align:middle. There … Read more

Padding a swift String for printing

In Swift 3 you can use: let str = “Test string” let paddedStr = str.padding(toLength: 20, withPad: ” “, startingAt: 0) Result string: “Test string ” If you need to pad to the left the text (right justify), you can write the following function as an extension to String: extension String { func leftPadding(toLength: Int, … Read more

Add bigger margin to EditText in Android AlertDialog

final AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity); final EditText input = new EditText(thisActivity); input.setSingleLine(); FrameLayout container = new FrameLayout(thisActivity); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin); input.setLayoutParams(params); container.addView(input); alert.setTitle(“by…”); alert.setMessage(“test message”); alert.setView(container); Make sure you add another line to your dimens.xml resource file, such as <dimen name=”dialog_margin”>20dp</dimen>