2014-12-11 52 views
0

我已經導入viewpagerindicator,但是當我編譯項目時,編譯器顯示錯誤。 錯誤消息是:錯誤:找不到包'com.example.sample'中屬性'lineWidth'的資源標識符 我使用的IDE是Intellij。 我該如何解決這個問題? 謝謝。Android版面錯誤:找不到包含屬性'lineWidth'的資源標識

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <com.viewpagerindicator.LinePageIndicator 
     android:id="@+id/indicator" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="3dp" 
     app:lineWidth="25dp" /> 

</RelativeLayout> 

回答

3

嘿,你需要把下面的vpi_attrs.xml文件放在values文件夾中。

<?xml version="1.0" encoding="utf-8"?> 


<resources> 
    <declare-styleable name="ViewPagerIndicator"> 
     <!-- Style of the circle indicator. --> 
     <attr name="vpiCirclePageIndicatorStyle" format="reference"/> 
     <!-- Style of the icon indicator's views. --> 
     <attr name="vpiIconPageIndicatorStyle" format="reference"/> 
     <!-- Style of the line indicator. --> 
     <attr name="vpiLinePageIndicatorStyle" format="reference"/> 
     <!-- Style of the title indicator. --> 
     <attr name="vpiTitlePageIndicatorStyle" format="reference"/> 
     <!-- Style of the tab indicator's tabs. --> 
     <attr name="vpiTabPageIndicatorStyle" format="reference"/> 
     <!-- Style of the underline indicator. --> 
     <attr name="vpiUnderlinePageIndicatorStyle" format="reference"/> 
    </declare-styleable> 

    <attr name="centered" format="boolean" /> 
    <attr name="selectedColor" format="color" /> 
    <attr name="strokeWidth" format="dimension" /> 
    <attr name="unselectedColor" format="color" /> 

    <declare-styleable name="CirclePageIndicator"> 
     <!-- Whether or not the indicators should be centered. --> 
     <attr name="centered" /> 
     <!-- Color of the filled circle that represents the current page. --> 
     <attr name="fillColor" format="color" /> 
     <!-- Color of the filled circles that represents pages. --> 
     <attr name="pageColor" format="color" /> 
     <!-- Orientation of the indicator. --> 
     <attr name="android:orientation"/> 
     <!-- Radius of the circles. This is also the spacing between circles. --> 
     <attr name="radius" format="dimension" /> 
     <!-- Whether or not the selected indicator snaps to the circles. --> 
     <attr name="snap" format="boolean" /> 
     <!-- Color of the open circles. --> 
     <attr name="strokeColor" format="color" /> 
     <!-- Width of the stroke used to draw the circles. --> 
     <attr name="strokeWidth" /> 
     <!-- View background --> 
     <attr name="android:background"/> 
    </declare-styleable> 

    <declare-styleable name="LinePageIndicator"> 
     <!-- Whether or not the indicators should be centered. --> 
     <attr name="centered" /> 
     <!-- Color of the unselected lines that represent the pages. --> 
     <attr name="unselectedColor" /> 
     <!-- Color of the selected line that represents the current page. --> 
     <attr name="selectedColor" /> 
     <!-- Width of each indicator line. --> 
     <attr name="lineWidth" format="dimension" /> 
     <!-- Width of each indicator line's stroke. --> 
     <attr name="strokeWidth" /> 
     <!-- Width of the gap between each indicator line. --> 
     <attr name="gapWidth" format="dimension" /> 
     <!-- View background --> 
     <attr name="android:background"/> 
    </declare-styleable> 

    <declare-styleable name="TitlePageIndicator"> 
     <!-- Screen edge padding. --> 
     <attr name="clipPadding" format="dimension" /> 
     <!-- Color of the footer line and indicator. --> 
     <attr name="footerColor" format="color" /> 
     <!-- Height of the footer line. --> 
     <attr name="footerLineHeight" format="dimension" /> 
     <!-- Style of the indicator. Default is triangle. --> 
     <attr name="footerIndicatorStyle"> 
      <enum name="none" value="0" /> 
      <enum name="triangle" value="1" /> 
      <enum name="underline" value="2" /> 
     </attr> 
     <!-- Height of the indicator above the footer line. --> 
     <attr name="footerIndicatorHeight" format="dimension" /> 
     <!-- Left and right padding of the underline indicator. --> 
     <attr name="footerIndicatorUnderlinePadding" format="dimension" /> 
     <!-- Padding between the bottom of the title and the footer. --> 
     <attr name="footerPadding" format="dimension" /> 
     <!-- Position of the line. --> 
     <attr name="linePosition"> 
      <enum name="bottom" value="0"/> 
      <enum name="top" value="1"/> 
     </attr> 
     <!-- Color of the selected title. --> 
     <attr name="selectedColor" /> 
     <!-- Whether or not the selected item is displayed as bold. --> 
     <attr name="selectedBold" format="boolean" /> 
     <!-- Color of regular titles. --> 
     <attr name="android:textColor" /> 
     <!-- Size of title text. --> 
     <attr name="android:textSize" /> 
     <!-- Padding between titles when bumping into each other. --> 
     <attr name="titlePadding" format="dimension" /> 
     <!-- Padding between titles and the top of the View. --> 
     <attr name="topPadding" format="dimension" /> 
     <!-- View background --> 
     <attr name="android:background"/> 
    </declare-styleable> 

    <declare-styleable name="UnderlinePageIndicator"> 
     <!-- Whether or not the selected indicator fades. --> 
     <attr name="fades" format="boolean" /> 
     <!-- Length of the delay to fade the indicator. --> 
     <attr name="fadeDelay" format="integer" /> 
     <!-- Length of the indicator fade to transparent. --> 
     <attr name="fadeLength" format="integer" /> 
     <!-- Color of the selected line that represents the current page. --> 
     <attr name="selectedColor" /> 
     <!-- View background --> 
     <attr name="android:background"/> 
    </declare-styleable> 
</resources> 

希望它能解決您的錯誤。請享用!!!

+0

謝謝,我解決了這個錯誤。但我有其他問題:在viewpagerindicator庫的values文件夾中有其他vip_xxx.xml文件,我需要在我的項目的值文件夾中添加該文件? – Elirex 2014-12-11 06:57:27

+0

是的。您需要添加所有vpi__colors,vpi__defaults,vpi__styles文件。 – 2014-12-11 07:00:57

相關問題