Reference Library-a library package with custom controls for custom properties

Source: Internet
Author: User

In general, when customizing a control panel and this control has a custom property (for example:panel:closedhandle= "@drawable/foot_bar_right"), you need to define a reference address for this control in the XML ( Example:xmlns:panel= "Http://schemas.android.com/apk/com.example.view")

This allows you to reference your custom control in XML.

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"//the package name where the panel resides   xmlns:panel= "Http://schemas.android.com/apk/com.example.view"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" >//Custom Control Panel<Com.example.view.Panel Android:id= "@+id/panel"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:layout_alignparentbottom= "true"android:layout_gravity= "Left"panel:closedhandle= "@drawable/foot_bar_right"panel:content= "@+id/panelcontent"Panel:handle= "@+id/panelhandle"Panel:openedhandle= "@drawable/foot_bar_left"panel:position= "Left" > </com.example.view.Panel>

But

When you want to reference a custom control that is a library , and this control also has a custom property, such as on (it has custom properties in Attrs.xml), you cannot reference the package name in the XML when it is referenced in the new project.

Instead, quote:xmlns:panel= "Http://schemas.android.com/apk/res-auto"

<relativelayout xmlns:android= thepackage name    where the "Http://schemas.android.com/apk/res/android"//panel is located Xmlns:panel= "Http://schemas.android.com/apk/res-auto"    android:layout_width= "Match_parent"    Android : layout_height= "Match_parent" >//Custom Control Panel    <com.example.view.panel        android:id= "@+id/ Panel "        android:layout_width=" fill_parent "        android:layout_height=" wrap_content "        android:layout_ Alignparentbottom= "true"        android:layout_gravity= "left"        panel:closedhandle= "@drawable/foot_bar_right"        panel:content= "@+id/panelcontent"        panel:handle= "@+id/panelhandle"        panel:openedhandle= "@ Drawable/foot_bar_left "        panel:position=" left ">    </com.example.view.Panel>

  

Reference Library-a library package with custom controls for custom properties

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.