I have been using zahid-ali-shah/SignatureView's SignatureView for a few years now and today implementing it on a new project I am unable to draw the signature and have tested it on both emulator and physical device.
This has been convenient in speeding up the process to capture user signatures as bitmaps, and hope it is just a simple fix. Also am curious if anyone else is having the same issue.
Wouldnt be a good question without some code, here is my view:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:title="#string/SIGNATURE_TOOLBAR_TITLE" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/signature_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.kyanogen.signatureview.SignatureView
xmlns:sign="http://schemas.android.com/apk/res-auto"
android:id="#+id/signature_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
sign:penSize="5dp"
sign:backgroundColor="#ffffff"
sign:penColor="#000000"
sign:enableSignature="false"/>
<Button
android:id="#+id/submit"
style="#style/ButtonStyle"
android:layout_width="161dp"
android:layout_height="47dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Submit Signature"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="#+id/clear"
style="#style/ButtonStyle"
android:layout_width="142dp"
android:layout_height="43dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:text="Clear"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
The Signature View is a Fragment "SignatureFragment" I am using Binding on the view and the "signature_view" is accessible using _binding
OnViewCreated:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
//Load UI Listeners
attachListeners()
}
attachListeners():
private fun attachListeners() {
//Signature Pad Setup
_binding?.signatureView?.penColor = Color.BLACK
//Load all of the listeners here for organization
_binding?.submit?.setOnClickListener(){
val signatureSubmitAction =
SignatureFragmentDirections.actionSignatureFragmentToRatingFragment()
findNavController().navigate(signatureSubmitAction)
}
_binding?.clear?.setOnClickListener {
confirmClearOfSignatureView()
}
}
confirmClearSignature():
private fun confirmClearOfSignatureView() {
//Create Alert Builder and Control Clear
val clearSignatureDialog = AlertDialog.Builder(context)
clearSignatureDialog.setTitle("Clear Signature?")
clearSignatureDialog.setMessage("Are you sure you want to clear your current signature? This operation is final.")
clearSignatureDialog.setPositiveButton("Yes, Clear") { dialog, which ->
_binding?.signatureView?.clearCanvas()
}
clearSignatureDialog.setNegativeButton("Don't Clear") { dialog, which ->
//Default Action is Dismiss
}
clearSignatureDialog.show()
}
From what I see in the documentation and my past experience, I should with the above be able to at least see the strokes on the screen. I am not able to see anything.
Any suggestions on what might be going on or how to resolve this? I would love to still use this Repo if possible.
I was unable to resolve this with the above library and switched to a better supported one:
implementation 'com.github.gcacace:signature-pad:1.3.1'
Updated Signature Pad
Related
I have a setOnClickListener() for a Google Pay Button in the OnCreate() in a fragment. I'm using viewbinding to get access to it.
override fun onCreate(savedInstanceState: Bundle?) {
setHasOptionsMenu(true)
super.onCreate(savedInstanceState)
binding = AddJobScreenBinding.inflate(layoutInflater)
paymentsClient = PaymentsUtil.createPaymentsClient(activity as Activity)
possiblyShowGooglePayButton()
binding.include.googlePayButton.setOnClickListener( { requestPayment() })
The PayButton is included in the xml of my fragment here:
<include
android:id="#+id/include"
layout="#layout/googlepay_button"
android:layout_width="378dp"
android:layout_height="69dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
this is the button itself:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="48sp"
android:background="#drawable/googlepay_button_no_shadow_background"
android:paddingTop="2sp"
android:contentDescription="#string/googlepay_button_content_description">
<LinearLayout
android:duplicateParentState="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:duplicateParentState="true"
android:src="#drawable/googlepay_button_content"/>
</LinearLayout>
<ImageView
android:id="#+id/googlePayButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:duplicateParentState="true"
android:scaleType="fitXY"
android:src="#drawable/googlepay_button_overlay" />
</RelativeLayout>
When the button gets clicked though the callback method requestPayment doesn't get called.
Why is this?
It seems that you are setting the click listener to an ImageView inside of the button. Try setting it to the button element itself:
binding.include.googlePayButton.setOnClickListener( { requestPayment() })
It'd be useful to give the element a more descriptive name too (eg.: #+id/googlePayButton).
Im surprised to be asking this, but my many searches are yielding absolutely nothing.
Im working on an AR application, in Android studio using ArCore & Sceneform.
It requires quite a bit of user input to provide some of the data for the AR Visualisations.
Im finding nothing about having a regular non ar menu system, in ARCore/Sceneform...i just want some kind of static interface akin to the regular android application gui type experience - Totally 2d and completely non-ar
Is this something that should be easy and straightforward, that im just over complicating? I already have an activity not in ArCore/Sceneform that does everything i need - I just simply need to push this data to the ar side any way i can.
You can have regular UI elements, button, input etc in a number of ways in your AR Sceneform application including:
using layouts to mix buttons and views with your Sceneform fragment
using alert dialogs to display messages and get input from a user
An example of a layout that supports the AR view and 'floating buttons' is:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="#+id/down_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/blank_button_bottom_right"
android:layout_margin="5dp"
android:src="#drawable/ic_baseline_arrow_downward_24px" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/right_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_above="#+id/blank_button_bottom_right"
android:layout_margin="5dp"
android:src="#drawable/ic_baseline_arrow_forward_24px" />
<fragment
android:id="#+id/ux_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</FrameLayout>
The above is simplified to make it more readable but you can see a full working example here: https://github.com/mickod/LineView
Using a dialog you can have a layout and code as below and add whatever EditText etc you need:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/main_info_text_view1"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:layout_marginRight="40dp"
android:text="#string/main_info_text1" />
<TextView
android:id="#+id/main_info_text_view2"
android:layout_below="#id/main_info_text_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:layout_marginRight="40dp"
android:text="#string/main_info_text2" />
<TextView
android:id="#+id/accreditations_info_text_view"
android:layout_below="#id/main_info_text_view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:layout_marginRight="40dp"
android:text="#string/accreditations_text" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
private fun infoDialog() {
//Display an info dialog
val builder = AlertDialog.Builder(this)
builder.setTitle("Info")
val inflater = layoutInflater
val settingsLayout = inflater.inflate(R.layout.info_layout, null)
// Display the layout and react to ok
builder.setView(settingsLayout)
builder.setPositiveButton("OK") { dialogInterface, i ->
return#setPositiveButton }
builder.show()
}
I am using TextInputLayout to take advantage of the floating hint and error display, the validation logic triggers when I press the continue button, it works fine if I don't select any textInput, the error is displayed correctly, but if I select a textInput, dismiss the keyboard and then press the continue button, the textInput is highlited in red as expected but the error text is not displayed.
What seems to be weird is that I tried the same code, same layout on a Acitvity and it worked fine (I am using a Fragment for this), but I would much rather stick to Fragment.
I also inspected the layout (when the error was not displayed) and the error textView seems to be there (in the view tree you can see the textView inside the TextInputLayout with a width of 0 and the text set to whatever I set it to)
My layout is:
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<TextView
android:id="#+id/text_acc_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:text="#string/sign_up_details"
android:textAppearance="#style/headerText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/linear_acc_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/text_acc_details">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/text_input_name"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:boxBackgroundMode="outline"
app:errorEnabled="true"
app:hintAnimationEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/sign_up_text_name"
android:inputType="text"
android:textColor="#color/textColour"
android:textSize="18sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/text_input_last_name"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/text_last_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/sign_up_text_last_name"
android:inputType="text"
android:textColor="#color/textColour"
android:textSize="18sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/text_input_email1"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/text_email1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/sign_up_text_email1"
android:inputType="text"
android:textColor="#color/textColour"
android:textSize="18sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/text_input_email2"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/text_email2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/sign_up_text_email2"
android:inputType="text"
android:textColor="#color/textColour"
android:textSize="18sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/button_sign_up_continue"
style="#style/PrimaryButton"
android:layout_width="300dp"
android:layout_marginBottom="23dp"
android:enabled="true"
android:text="#string/sign_up_button_continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
My Fragment code:
class SignUpFragment: Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
val rootView = inflater.inflate(R.layout.fragment_sign_up, container, false)
return rootView
}
override fun onStart() {
super.onStart()
button_sign_up_continue.setOnClickListener {
validateText()
}
}
private fun validateText() {
if (text_name.text.isNullOrEmpty()) {
text_input_name.error = resources.getText(R.string.sign_up_error_text)
} else {
text_input_name.error = null
}
if (text_last_name.text.isNullOrEmpty()) {
text_input_last_name.error = resources.getText(R.string.sign_up_error_text)
} else {
text_input_last_name.error = null
}
val isValidEmail = Patterns.EMAIL_ADDRESS.toRegex().matches(text_email1.text.toString())
if (text_email1.text.isNullOrEmpty() || !isValidEmail) {
text_input_email1.error = resources.getText(R.string.sign_up_invalid_email)
} else {
text_input_email1.error = null
}
}
The gif shows how by tapping the button first works fine, but if I select a textInput first and then tap the button the error text is not displayed (it is set and is there by checking in the layout inspector tool but the width is 0 for some reason)
After spending quite a lot of time in this issue, I found out that this seems to be a Material Android issue (at least on com.google.android.material:material:1.1.0 library version), you can find the issue tracker here:
https://issuetracker.google.com/issues/136435162
For the time being I found a work around to fix the errorTextView's width issue by creating a TextInputLayout extension and updating the errorTextView width manually:
val errorTextView = this.findViewById<TextView>(R.id.textinput_error)
var params = errorTextView?.layoutParams
params?.width = yourWidth
errorTextView?.layoutParams = params
It is not pretty but it does the trick for now, hope it helps someone
Put this method inside onActivityCreated() instead of onStart()
button_sign_up_continue.setOnClickListener {
validateText()
}
I am trying to make a layout with an Edit Text field for email requests. The design makes it so that the keyboard is always opened over the editText View which makes it impossible to know what you are entering. I have tried many suggestions on stack overflow but most of them are for API <24 (though I don't think this has much effect on this).
In the Activity file I have tried the following:
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
In Android Manifest I have also tried the following, both in conjunction and separately:
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="stateHidden|adjustPan"
android:windowSoftInputMode="adjustResize"
I also wrapped my layout in a ScrollView as described by Heena
here : https://stackoverflow.com/a/39867438/5635144
Below is my XML and the accompanying activity
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EmailResetActivity">
<RelativeLayout
android:id="#+id/bg"
android:layout_width="match_parent"
android:layout_height="419dp"
android:background="#drawable/signin_up_anim"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
<EditText
android:id="#+id/e_request"
android:layout_width="305dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="#string/email_address"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingBottom="15dp"
android:textColorHint="#color/hintgrey"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.522"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/bg" />
<LinearLayout
android:layout_width="wrap_content"
android:id="#+id/buttonsContainer"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/e_request">
<Button
android:id="#+id/sendRequestBtn"
android:layout_width="150dp"
android:layout_height="45dp"
android:background="#drawable/large_btn"
android:text="#string/submit"
android:textColor="#color/white" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
class EmailResetActivity : AppCompatActivity() {
lateinit private var auth: FirebaseAuth
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_email_reset)
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN or WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
auth = FirebaseAuth.getInstance()
val animDrawable = resetPassInfoBg.background as AnimationDrawable
animDrawable.setEnterFadeDuration(2500)
animDrawable.setExitFadeDuration(1500)
animDrawable.start()
sendRequestBtn.setOnClickListener(View.OnClickListener {
val email = e_request.getText().toString().trim()
if (TextUtils.isEmpty(email)) {
Toast.makeText(application, "Enter your email ", Toast.LENGTH_SHORT).show()
return#OnClickListener
}
})
}
}
I would like for the layout to be moved up so the editText Field is visible but currently nothing is making it work.
Remove this line:
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
With FLAG_LAYOUT_NO_LIMITS the application is not able to calculate how to scroll your view, because your layout has no limits.
I have enabled databinding, but while I execute the code I get this error.
error
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
I created a fragment class and XML for that class.
Im able to import datbindingutil class.
I have done rebuilt/ sync with gradle files/ invalidate cache and restart, nothing worked.
xml
<layout>
<!--suppress AndroidUnknownAttribute -->
<data class=".databinding.ProfileFragmentBinding">
<variable
name="user"
type="com.sample.sample.user.User" />
<variable
name="vm"
type="com.sample.sample.user.UserViewModel" />
<variable
name="handler"
type="com.sample.sample.user.profile.ProfileFragment" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profileIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/medium"
android:layout_marginTop="#dimen/medium"
android:contentDescription="#null"
android:src="#mipmap/ic_launcher_round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:url="#{user.avatarUrl}" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="#+id/profileIV"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/profileIV">
<TextView
android:id="#+id/profileNameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/myriad_pro_semibold"
android:text="#{user.name}"
android:textColor="#color/black_transparent_de"
android:textSize="#dimen/text_regular"
tools:text="NAME" />
<TextView
android:id="#+id/badgeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="#font/myriad_pro_semibold"
android:text="#{user.badge}"
android:textColor="#color/grey_000000"
android:textSize="#dimen/text_regular"
tools:text="Superman" />
<TextView
android:id="#+id/profile_Label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="#font/roboto_bold"
android:text="#{user.badge}"
android:textColor="#color/green_39b54a"
android:textSize="#dimen/text_small"
tools:text="farmer_v1" />
</LinearLayout>
<ImageView
android:id="#+id/badgeIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/medium"
android:layout_marginTop="#dimen/medium"
android:contentDescription="#null"
android:src="#mipmap/ic_launcher"
app:error="#{#drawable/ic_profile_default_grey_24dp}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:placeholder="#{#drawable/ic_profile_default_grey_24dp}"
app:url="#{user.badgeUrl}" />
<ImageView
android:id="#+id/locationPinIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/medium"
android:contentDescription="#null"
android:src="#drawable/ic_location_pin"
app:layout_constraintStart_toStartOf="#+id/profileIV"
app:layout_constraintTop_toBottomOf="#+id/profileIV" />
<TextView
android:id="#+id/profileAddressTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/narrow"
android:fontFamily="#font/roboto"
android:textColor="#color/grey_000000"
app:layout_constraintBottom_toBottomOf="#+id/locationPinIV"
app:layout_constraintLeft_toRightOf="#+id/locationPinIV"
app:layout_constraintTop_toTopOf="#+id/locationPinIV"
tools:text="bangalore, Karnataka" />
<ImageView
android:id="#+id/dobIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/standard"
android:layout_marginTop="#dimen/medium"
android:contentDescription="#null"
android:src="#drawable/ic_dob"
app:layout_constraintLeft_toRightOf="#+id/profileAddressTV"
app:layout_constraintTop_toBottomOf="#+id/profileIV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/narrow"
android:fontFamily="#font/roboto"
android:textColor="#color/grey_000000"
app:layout_constraintBottom_toBottomOf="#+id/locationPinIV"
app:layout_constraintLeft_toRightOf="#+id/dobIV"
app:layout_constraintTop_toTopOf="#+id/locationPinIV"
tools:text="born on 01/01/2000" />
<TextView
android:id="#+id/activityLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/big"
android:fontFamily="#font/myriad_pro_semibold"
android:text="#string/activities"
android:textColor="#color/black_transparent_de"
android:textSize="#dimen/text_regular"
app:layout_constraintStart_toStartOf="#+id/profileIV"
app:layout_constraintTop_toBottomOf="#+id/locationPinIV" />
<View
android:id="#+id/dividerV"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginEnd="#dimen/small"
android:layout_marginStart="#dimen/small"
android:layout_marginTop="#dimen/regular"
android:background="#color/grey_000000"
app:layout_constraintTop_toBottomOf="#+id/activityLabel" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="#+id/dividerV">
<!--<com.google.android.material.tabs.TabLayout
android:id="#+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:pager="#{(pager)}"
app:tabGravity="fill"
app:tabIndicatorColor="#color/black"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/black"
app:tabTextAppearance="#style/CustomTextTab"
app:tabTextColor="#b4ffffff" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tablayout"
app:handler="#{handler}"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />-->
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
class
class ProfileFragment : Fragment() {
#Inject
lateinit var mFactory: ViewModelProvider.Factory
private lateinit var mBinding: ProfileFragmentBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_profile, container, false);
return mBinding.root
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val vm: UserViewModel = getViewModel(mFactory)
mBinding.vm = vm
//mBinding.handler = this
//mBinding.setLifecycleOwner(this)
}
/*#BindingAdapter("bind:handler")
fun bindViewPagerAdapter(view: ViewPager, activity: MainActivity) {
val adapter = ProfilePagerAdapter(view.context, activity.supportFragmentManager)
view.adapter = adapter
}
#BindingAdapter("bind:pager")
fun bindViewPagerTabs(view: TabLayout, pagerView: ViewPager) {
view.setupWithViewPager(pagerView, true)
}*/
}
in my case I was able to find it when the mouse was hovering that line in the build output, as shown here:
without hover:
with hover:
it's really a shame how they show the error, for the simplest error ever, I was trying 10 different solutions as well invalidating the cache and ...
UPDATE:
you can also click here :
and you'll get something like this:
which is very detailed information about the error, I was missing this button in 7 years of Android Development :D
Run ./gradlew build --stacktrace to check the details, which will tell you where the issue happens, something like:
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
Could not find accessor xx
file:xxx/app/src/main/res/layout/fragment_xxxx.xml Line:108
Sometimes if you changed the property name, especially when changed by refactor => rename, the property name won't be changed in xml automatically.
Mostly this error occurs when the name of the variable passed in the XML file through data binding is incorrect. Just hover over the mouse on the error and you would be able to identify the culprit variable there.
if it happen when change jdk versions, delete all build folders in every module that you have on the project,
It's fixed my issue.
delete caches folder to
finder -> home -> click on "command +shift + ." to see hidden folders -> .gradle -> caches