custom password textfield in android studio programmatically - java

how can I make a custom password textfield like the picture in android programmatically java ? (or XML)
Im only interested to the textfield (the keyboard is android's system)
thank you
Password TextField Image

Import library in app.gralde
implementation 'com.poovam:pin-edittext-field:1.2.3'
XML layout for password field
<com.poovam.pinedittextfield.CirclePinField
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
app:noOfFields="4"
android:textSize="16sp"
android:textSelectHandle="#drawable/text_handle"
app:circleRadius="15dp"
app:fillerRadius="2dp"
app:fillerColor="#color/colorPrimary"
app:fieldBgColor="#ddd"
android:id="#+id/circleField"/>
Reference : https://github.com/poovamraj/PinEditTextField

I think this library can help you. It's easy and simple.
https://github.com/alphamu/PinEntryEditText
You just go to that link and follow the steps.

Related

No speakable text present at Android Studio

When adding a field for entering a number(Number widget), the error "No speakable text present at Android Studio" takes off
enter image description here
content_main.xml: enter image description here
activity_main.xml: enter image description here
The problem is you are missing content labeling for the view, you should add content description so the user could simply understand what data he should enter into the view
for example, if you want the user to enter the number of cookies he wants you should add a content description as seen below:
android:contentDescription="Enter How Much Cookies You Want"
You should also add an android:hint so the user would have it in front of them an example of the data you want inputted for example:
android:hint="e.g 5"
So your views XML code should look as follows
<EditText
android:id="#+id/editTextNumber2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:minHeight="48dp"
android:contentDescription="Enter How Much Cookies You Want"
android:hint="e.g 8" />
The solution is simple you just need to add the text into the hint part.
search hint in search-bar ant type something in hint block.
and hit Enter.enter image description here
The problem is missing constraints. Any view you add in Constraint layout, you must set the margins otherwise you will get those errors and even if your app managed to run, your edit text will not be place properly.
Add this to your editText;
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Let me know if it worked.
Remember you can twick this to your desired position.

How to change Button app:icon property programitically

I have a button with centralized icon+text, and I need to change the app:icon and android:text properties when some event occurred. I know that there is setText() method to change the text, but is there a way to change the icon?
XML:
<Button
android:id="#+id/bottom_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="#dimen/default_margin"
android:layout_marginVertical="#dimen/bottom_bar_content_vertical_margin"
android:backgroundTint="#color/light_green"
android:text="#string/next"
android:textAllCaps="false"
app:icon="#drawable/ic_baseline_next_plan_24"
app:iconGravity="textStart" />
This is a function that is called after appropriate event, and I need to change icon in that function. icon and text are ids of desirable drawable and string:
private void setBottomButton(int icon, int text) {
button.setText(getString(text));
}
You can use the methods:
setIcon
setIconResource
Example:
button.setIcon(drawable)
button.setIconResource(iconId)
Here the doc.
If you check the docs, you'll see the code equivalent for each XML attribute.
Check this link : enter link description here
Searching for drawableLeft shows:
android:drawableLeft:
setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)

How do I add someone's website link in my Android app?

I want to add some ticket booking links in my app. How do I add? I used webview that open the links in a browser. But is it correct?
You can simply use TextView to add link in your app.
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/link_to_google"
/>
To make your string as link, add your string in String.xml..for example
<string name="link_to_google"><a href="http://www.google.com">Go to
Google</a></string>
and at last, call setMovementMethod on your textView
TextView textView =findViewById(R.id.textView);
textView.setMovementMethod(LinkMovementMethod.getInstance());

How to Stop Animation of the Arrow of the SpeedView in Android Using Speedometer library

I tried to stop the Animation of arrow in the speedview through the java code but is not working.
<com.github.anastr.speedviewlib.SpeedView
android:id="#+id/performance_speedometer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
app:sv_endDegree="#integer/degree360"
app:sv_startDegree="#integer/degree180"
app:sv_unit="" />
Java
binding.performanceSpeedometer.setLowSpeedPercent(25);
binding.performanceSpeedometer.setLowSpeedColor(Color.RED);
binding.performanceSpeedometer.setMediumSpeedPercent(50);
binding.performanceSpeedometer.setMediumSpeedColor(Color.YELLOW);
binding.performanceSpeedometer.setHighSpeedColor(Color.GREEN);
binding.performanceSpeedometer.setTextSize(0);
binding.performanceSpeedometer.setSpeedTextSize(0);
binding.performanceSpeedometer.speedTo(12f);
try this:
no need to write any code in java just add this line to xml
app:sv_withTremble="false"
If you need change programmatically in code:
speedometer.setWithTremble(false);

How can I update a property in xml binding?

I want to use a way of bindings like this:
<ImageView
android:id="#+id/play"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#{play.isEnabled() ? #drawable/round_button : #drawable/round_disable_button}"
android:src="#drawable/play" />
I want that binding get updated when I disable or enable that ImageView in Java class, how can I do this?
You can't
Practically, you can create a custom view, extended from ImageView, and do this pragmatically.
Edit: you can use MVVM third party library for android like this: https://github.com/manas-chaudhari/android-mvvm

Categories