Android custom keyboard, code implementation custom properties (custom keyboard background, background of individual keys, etc.)

Source: Internet
Author: User

The custom keyboard was contacted because of the work required. But found that the keyboard is too ugly to write some. No more nonsense, first.

The first one is modified. The second one is to change the money. This is basically

Ok. The next step is the point.

The Keyboardview properties of Android are Keybackground, but when used, they are found not to be effective. Carefully read the next source to find. The following sentence sets the property set to null. Therefore, the properties of the keyboard have not been effective.

New Keyboardview (thisnull);  

The tragedy happened. It's going to be a solution. Since this is known, the attribute collection is empty. Then set the property collection to be. Review API Discovery. A lot of methods. One of the methods is chosen.

Xmlpullparser parser =activity.getresources (). GETXML (R.layout.keyboardview); AttributeSet attributes=Xml.asattributeset (parser); inttype; Try{               while(type = Parser.next ())! = Xmlpullparser.start_tag &&type!=xmlpullparser.end_document) {                  //Empty            }              if(Type! =Xmlpullparser.start_tag) {LOG.E ("", "the XML file is error!\n"); }             } Catch(xmlpullparserexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } log.d ("",""+Parser.getattributecount ()); Keyboardview Mkeyboardview=NewKeyboardview ( This, attributes); Mkeyboardview.setfocusable (true); Mkeyboardview.setfocusableintouchmode (true);        Mkeyboardview.setid (R.id.keyboard_view);        Mkeyboardview.setvisibility (View.gone); Relativelayout.layoutparams LP=Newrelativelayout.layoutparams (RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATC        H_parent);        Lp.addrule (Relativelayout.align_parent_bottom, relativelayout.true); Relativelayout Rlyt=NewRelativelayout ( This); Rlyt.addview (Mkeyboardview, LP);
Keyboardview.xml is a collection of properties that are stored in the keyboard keyboardview. Setting a collection in this place is not a fear of not taking effect.
<?xml version= "1.0" encoding= "Utf-8"? ><android.inputmethodservice.keyboardview xmlns:android= "/http Schemas.android.com/apk/res/android "    android:layout_width=" Fill_parent "    android:layout_ Height= "wrap_content"    android:layout_alignparentbottom= "true"    Android:background = "@color/lightblack"    android:focusable= "true"    android:focusableintouchmode= " True "    android:keybackground=" @drawable/btn_keyboard_key "    android:keytextcolor= "@color/white"    android:visibility= "Gone"/>

This is how the custom skin of the keyboard is implemented.

Android custom keyboard, code implementation custom properties (custom keyboard background, background of individual keys, etc.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.