How do I create a multiline TextField in SwiftUI?

iOS 16 – beta TextFields can be configured to expand vertically using the new axis parameter. Also it takes the lineLimit modifier to limit the lines in the given range: TextField(“Title”, text: $text, axis: .vertical) .lineLimit(5…10) But the lineLimit modifier now also supports more advanced behaviors, like reserving a minimum amount of space and expanding … Read more

How To Set Text In An EditText

If you check the docs for EditText, you’ll find a setText() method. It takes in a String and a TextView.BufferType. For example: EditText editText = (EditText)findViewById(R.id.edit_text); editText.setText(“This sets the text.”, TextView.BufferType.EDITABLE); It also inherits TextView‘s setText(CharSequence) and setText(int) methods, so you can set it just like a regular TextView: editText.setText(“Hello world!”); editText.setText(R.string.hello_world);

How to draw rounded rectangle in Android UI?

In your layout xml do the following: <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <solid android:color=”@android:color/holo_red_dark” /> <corners android:radius=”32dp” /> </shape> By changing the android:radius you can change the amount of “radius” of the corners. <solid> is used to define the color of the drawable. You can use replace android:radius with android:bottomLeftRadius, android:bottomRightRadius, android:topLeftRadius and android:topRightRadius to define radius … Read more

Multiline TextView in Android?

If the text you’re putting in the TextView is short, it will not automatically expand to four lines. If you want the TextView to always have four lines regardless of the length of the text in it, set the android:lines attribute: <TextView android:id=”@+id/address1″ android:gravity=”left” android:layout_height=”fill_parent” android:layout_width=”wrap_content” android:maxLines=”4″ android:lines=”4″ android:text=”Lorem ipsum dolor sit amet, consectetur adipisicing … Read more

How to set a ripple effect on textview or imageview on Android?

Ref : http://developer.android.com/training/material/animations.html, http://wiki.workassis.com/category/android/android-xml/ <TextView . . android:background=”?attr/selectableItemBackgroundBorderless” android:clickable=”true” /> <ImageView . . . android:background=”?attr/selectableItemBackgroundBorderless” android:clickable=”true” />

Different font size of strings in the same TextView

Use a Spannable String String s= “Hello Everyone”; SpannableString ss1= new SpannableString(s); ss1.setSpan(new RelativeSizeSpan(2f), 0,5, 0); // set size ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, 5, 0);// set color TextView tv= (TextView) findViewById(R.id.textview); tv.setText(ss1); Snap shot You can split string using space and add span to the string you require. String s= “Hello Everyone”; String[] each = s.split(” … Read more

dpi value of default “large”, “medium” and “small” text views android

See in the android sdk directory. In \platforms\android-X\data\res\values\themes.xml: <item name=”textAppearanceLarge”>@android:style/TextAppearance.Large</item> <item name=”textAppearanceMedium”>@android:style/TextAppearance.Medium</item> <item name=”textAppearanceSmall”>@android:style/TextAppearance.Small</item> In \platforms\android-X\data\res\values\styles.xml: <style name=”TextAppearance.Large”> <item name=”android:textSize”>22sp</item> </style> <style name=”TextAppearance.Medium”> <item name=”android:textSize”>18sp</item> </style> <style name=”TextAppearance.Small”> <item name=”android:textSize”>14sp</item> <item name=”android:textColor”>?textColorSecondary</item> </style> TextAppearance.Large means style is inheriting from TextAppearance style, you have to trace it also if you want to see full definition of … Read more