ID和公共资源链接失败

时间:2018-11-09 10:19:58

标签: android

我正在尝试为android studio创建dimens xml,ids xml和public xml,所以我可以拥有id,以便可以调用所需的每个布局xml,因为我不需要一次又一次地编写相同的编码。 但这使我感到困惑,因为它在声明的xml中没有显示任何错误,但是它没有起作用。 我有Invalide缓存并重新启动,但是没有用。 如果我写的代码不好,请告诉我。

这是我的代码。 activity_main

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/container"
    style="@style/ActivityMain">
    <LinearLayout android:id="@+id/linLayoutMainSearch" style="LinearLayoutSearch">
        <LinearLayout android:id="@id/linearLayoutOutsideSearch" style="@style/LinearLayoutOutsideSearch.Search">
            <LinearLayout style="@style/LinearLayoutInsideSearch">
                <LinearLayout android:orientation="horizontal" android:id="@id/linLayoutAutoFocus" style="@style/LinearLayoutAutoFocus" />
                <FrameLayout android:layout_gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0">
                    <EditText android:id="@id/etSearch" android:imeOptions="actionGo|flagNoExtractUi" style="@style/SearchEditText.MainSearch" />
                    <LinearLayout android:orientation="vertical" android:id="@id/layoutWithFakeCursor" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content">
                        <ImageView android:id="@id/ivCursor" android:background="@drawable/kursor" android:layout_width="2.0dip" android:layout_height="20.0dip" android:layout_marginLeft="6.0dip" />
                    </LinearLayout>
                </FrameLayout>
                <ImageButton android:layout_gravity="center" android:id="@id/imgBtnBookmark" android:background="@drawable/selector_gray_btn" android:paddingTop="3.0dip" android:paddingRight="7.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_reading_list" android:scaleType="center" android:scaleX="0.8" android:scaleY="0.8" />
                <ImageButton android:id="@id/btnClearSearch" style="@style/ImageButtonClose" />
            </LinearLayout>
            <Button android:id="@id/btnSearch" style="@style/ButtonSearch" />
            <ImageView android:id="@id/imgBtnHome" style="@style/ImageViewHome" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="upDivider" type="id">false</item>
    <item name="linLayoutMainSearch" type="id">false</item>
    <item name="linLayoutAutoFocus" type="id">false</item>
    <item name="linearLayoutOutsideSearch" type="id">false</item>
    <item name="etSearch" type="id">false</item>
    <item name="layoutWithFakeCursor" type="id">false</item>
    <item name="ivCursor" type="id">false</item>
    <item name="imgBtnBookmark" type="id">false</item>
    <item name="btnClearSearch" type="id">false</item>
    <item name="btnSearch" type="id">false</item>
    <item name="imgBtnHome" type="id">false</item>
</resources>

public.xml

<resources>
    <public name="imgBtnHome" id="0x7f0b0089" type="id" />
    <public name="btnSearch" id="0x7f0b0088" type="id" />
    <public name="btnClearSearch" id="0x7f0b0087" type="id" />
    <public type="id" name="imgBtnBookmark" id="0x7f0b0086" />
    <public type="id" name="ivCursor" id="0x7f0b0085" />
    <public type="id" name="layoutWithFakeCursor" id="0x7f0b0084" />
    <public type="id" name="etSearch" id="0x7f0b0083" />
    <public type="style" name="LinearLayoutOutsideSearch" id="0x7f08011d" />
    <public type="id" name="linLayoutAutoFocus" id="0x7f0b0082" />
    <public type="id" name="linLayoutMainSearch" id="0x7f0b0080" />
    <public type="id" name="upDivider" id="0x7f0b009b" />

</resources>

dimens.xml

<resources>
    <dimen name="search_height">42dp</dimen>
    <dimen name="search_font">15sp</dimen>
</resources>

styles.xml

<resource>
  <!-- <style name="ImageViewHome">
        <item name="android:layout_gravity">center</item>
        <item name="android:background">@drawable/selector_gray_btn</item>
        <item name="android:paddingLeft">4.0dip</item>
        <item name="android:paddingTop">4.0dip</item>
        <item name="android:paddingBottom">4.0dip</item>
        <item name="android:layout_width">37.0dip</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:src">@drawable/ic_home_button</item>
        <item name="android:scaleType">fitCenter</item>
    </style>

    <style name="ActivityMain">
        <item name="android:background">@android:color/white</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>

    </style>
    <style name="LinearLayoutSearch">
        <item name="android:orientation">vertical</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:layout_below">@id/upDivider</item>
    </style>
    <style name="LinearLayoutInsideSearch">
        <item name="android:layout_gravity">center</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:background">@android:color/white</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">35.0dip</item>
        <item name="android:layout_marginLeft">2.0dip</item>
        <item name="android:layout_weight">1.0</item>
    </style>
    <style name="LinearLayoutAutoFocus">
        <item name="android:focusable">true</item>
        <item name="android:focusableInTouchMode">true</item>
        <item name="android:layout_width">0.0dip</item>
        <item name="android:layout_height">0.0dip</item>
    </style>
    <style name="LinearLayoutOutsideSearch.Search" parent="@style/LinearLayoutOutsideSearch">
        <item name="android:paddingRight">7.0dip</item>
    </style>
    <style name="LinearLayoutOutsideSearch">
        <item name="android:orientation">horizontal</item>
        <item name="android:background">@android:color/white</item>
        <item name="android:paddingLeft">3.0dip</item>
        <item name="android:paddingTop">3.0dip</item>
        <item name="android:paddingRight">3.0dip</item>
        <item name="android:paddingBottom">3.0dip</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">@dimen/search_height</item>
    </style>
    <style name="SearchEditText" parent="@android:style/Widget.EditText">
        <item name="android:buttonStyle">@style/LowerCaseTextBtn</item>
        <item name="android:textSize">@dimen/search_font</item>
        <item name="android:textColor">@android:color/black</item>
        <item name="android:textColorHighlight">@color/edit_text_color_highlight</item>
        <item name="android:textColorHint">@color/gray</item>
        <item name="android:gravity">center_vertical</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:layout_weight">1.0</item>
        <item name="android:textCursorDrawable">@drawable/edit_text_cursor</item>
    </style>
    <style name="SearchEditText.MainSearch" parent="@style/SearchEditText">
        <item name="android:paddingLeft">6.0dip</item>
        <item name="android:hint">@string/SVSearchTextFieldPlaceholder</item>
        <item name="android:imeOptions">actionGo</item>

    </style>
    <style name="LowerCaseTextBtn" parent="@android:style/Widget">
        <item name="android:textStyle">normal</item>
        <item name="android:textAllCaps">false</item>
    </style>
    <style name="ImageButtonClose">
        <item name="android:layout_gravity">center|right</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="android:paddingLeft">7.0dip</item>
        <item name="android:paddingTop">6.0dip</item>
        <item name="android:paddingRight">12.0dip</item>
        <item name="android:paddingBottom">5.0dip</item>
        <item name="android:visibility">gone</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:src">@drawable/ic_close</item>
    </style>
    <style name="ButtonSearch" parent="@style/LowerCaseTextBtn">
        <item name="android:textSize">15.0sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/urlSuggest</item>
        <item name="android:gravity">center</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:background">@drawable/selector_gray_btn</item>
        <item name="android:visibility">gone</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:text">@string/SVSearchButton</item>
    </style>-->
</resource>

0 个答案:

没有答案