D devlei Active Member Licensed User Longtime User Jun 12, 2013 #1 Input fields on a form include EditText & Label views. I would like both types of views to have a consistent appearance (background & text colors) for all Android versions (and/or devices). The Labels' appearance I set from the Designer and they remain consistent, but the EditText's appearance is different across devices. I can't see how to set the EditText's appearance from the designer and could not find an example of how to set it by code. Any assistance would be much appreciated!!
Input fields on a form include EditText & Label views. I would like both types of views to have a consistent appearance (background & text colors) for all Android versions (and/or devices). The Labels' appearance I set from the Designer and they remain consistent, but the EditText's appearance is different across devices. I can't see how to set the EditText's appearance from the designer and could not find an example of how to set it by code. Any assistance would be much appreciated!!
klaus Expert Licensed User Longtime User Jun 12, 2013 #2 You could create your own 9 patch image and set it to the EditText views. Attached a small test project, the image is taken from Erel's tutorial. For more detatails you should read chapter 9.1.5 NinePatchDrawable in the User's Guide. Unfortunately, the example program in the User's Guide Source Code doesn't work, the Object folder is missing. I attached it below. Best regards. Attachments EditText9Patch.zip EditText9Patch.zip 6.9 KB · Views: 378 NinePatchExample.zip NinePatchExample.zip 9.7 KB · Views: 352 Upvote 0
You could create your own 9 patch image and set it to the EditText views. Attached a small test project, the image is taken from Erel's tutorial. For more detatails you should read chapter 9.1.5 NinePatchDrawable in the User's Guide. Unfortunately, the example program in the User's Guide Source Code doesn't work, the Object folder is missing. I attached it below. Best regards.
D devlei Active Member Licensed User Longtime User Jun 12, 2013 #3 Thank you for the response,Klaus. I had hoped it would be simpler. Is it not possible to just set the EditText.Background property via code? If so, is there an example somewhere? Upvote 0
Thank you for the response,Klaus. I had hoped it would be simpler. Is it not possible to just set the EditText.Background property via code? If so, is there an example somewhere?
klaus Expert Licensed User Longtime User Jun 12, 2013 #4 You can do it with this code: Code: EditText2.Initialize("EditText2") Activity.AddView(EditText2, 50dip, 70dip, 150dip, 50dip) Dim cdw As ColorDrawable cdw.Initialize(Colors.White, 5dip) EditText2.Background = cdw I proposed you the 9path image because it is much more versatile and could have something similar to the older EditText view background. Best regards. Upvote 0
You can do it with this code: Code: EditText2.Initialize("EditText2") Activity.AddView(EditText2, 50dip, 70dip, 150dip, 50dip) Dim cdw As ColorDrawable cdw.Initialize(Colors.White, 5dip) EditText2.Background = cdw I proposed you the 9path image because it is much more versatile and could have something similar to the older EditText view background. Best regards.
D devlei Active Member Licensed User Longtime User Jun 12, 2013 #5 Thanks, Klaus, this example is exactly what I was looking for. I have subsequently also found it in your User Guide in section 9. Your help is much appreciated!!! Upvote 0
Thanks, Klaus, this example is exactly what I was looking for. I have subsequently also found it in your User Guide in section 9. Your help is much appreciated!!!