代码之家  ›  专栏  ›  技术社区  ›  Ittai Oren

重写exoplayer控制器会出现错误:(27,34)未找到与给定名称匹配的资源(在“id”处,值为“@id/exo\u next”)

  •  1
  • Ittai Oren  · 技术社区  · 7 年前

    我创建了一个名为

    exo\u playback\u control\u view.xml

    根据 this SO question

    这是我的xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingTop="4dp"
        android:orientation="horizontal">
    
        <ImageButton android:id="@id/exo_prev"
            style="@style/ExoMediaButton.Previous"/>
    
        <ImageButton android:id="@id/exo_rew"
            style="@style/ExoMediaButton.Rewind"/>
    
        <ImageButton android:id="@id/exo_play"
            style="@style/ExoMediaButton.Play"/>
    
        <ImageButton android:id="@id/exo_pause"
            style="@style/ExoMediaButton.Pause"/>
    
        <ImageButton android:id="@id/exo_ffwd"
            style="@style/ExoMediaButton.FastForward"/>
    
        <ImageButton android:id="@id/exo_next"
            style="@style/ExoMediaButton.Next"/>
    
        // This is the custom button
        <ImageButton
            android:id="@+id/exo_fullscreen_button"
            style="@style/ExoMediaButton"
            android:src="@drawable/ic_fullscreen"/>
    </LinearLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">
    
        <TextView android:id="@id/exo_position"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:textStyle="bold"
            android:paddingLeft="4dp"
            android:paddingRight="4dp"
            android:includeFontPadding="false"
            android:textColor="#FFBEBEBE"/>
    
        <SeekBar android:id="@id/exo_progress"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="32dp"
            android:focusable="false"
            style="?android:attr/progressBarStyleHorizontal"/>
    
        <TextView android:id="@id/exo_duration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:textStyle="bold"
            android:paddingLeft="4dp"
            android:paddingRight="4dp"
            android:includeFontPadding="false"
            android:textColor="#FFBEBEBE"/>
    
    </LinearLayout>
    

    这些是我得到的错误

    Error:(15, 34) No resource found that matches the given name (at 'id' with value '@id/exo_rew').
    Error:(18, 34) No resource found that matches the given name (at 'id' with value '@id/exo_play').
    Error:(19, 20) No resource found that matches the given name (at 'style' with value '@style/ExoMediaButton.Play').
    Error:(21, 34) No resource found that matches the given name (at 'id' with value '@id/exo_pause').
    Error:(22, 20) No resource found that matches the given name (at 'style' with value '@style/ExoMediaButton.Pause').
    Error:(24, 34) No resource found that matches the given name (at 'id' with value '@id/exo_ffwd').
    Error:(27, 34) No resource found that matches the given name (at 'id' with value '@id/exo_next').
    Error:(44, 31) No resource found that matches the given name (at 'id' with value '@id/exo_position').
    Error:(54, 30) No resource found that matches the given name (at 'id' with value '@id/exo_progress').
    Error:(61, 31) No resource found that matches the given name (at 'id' with value '@id/exo_duration').
    Error:Execution failed for task ':app:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute aapt
    

    3 回复  |  直到 7 年前
        1
  •  0
  •   Mohammed Farhan    7 年前
    <ImageView
        android:id="@+id/nearestPhoneIV"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginBottom="5dp"
         android:layout_marginLeft="30dp"
         android:layout_marginRight="30dp"
         android:layout_marginTop="5dp"
         android:src="@drawable/phone"/>
    

    "@+id/idname"

        2
  •  0
  •   Sonam Gupta    7 年前
    <TextView android:id="@+id/exo_position"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="14sp"
        android:textStyle="bold"
        android:paddingLeft="4dp"
        android:paddingRight="4dp"
        android:includeFontPadding="false"
        android:textColor="#FFBEBEBE"/>
    

    @id/exo\u位置用于重用视图的id,@+id/exo\u位置用于声明新的视图id。

        3
  •  0
  •   AllwiN    5 年前

    <style name="CustomExoMediaButton">
       <item name="android:background">?android:attr/selectableItemBackground</item>
       <item name="android:scaleType">fitXY</item>
       <item name="android:layout_width">@dimen/video_view_exo_player_play_pause_button_dimen</item>
       <item name="android:layout_height">@dimen/video_view_exo_player_play_pause_button_dimen</item>
    </style>
    
    <style name="CustomExoMediaButton.Play">
       <item name="android:src">@drawable/ic_play_circle_filled</item>
    </style>
    
    <style name="CustomExoMediaButton.Pause">
       <item name="android:src">@drawable/ic_pause_circle_filled</item>
    </style>

    Link 对于您实施的内容。