2016-10-25 1 views
1

선택기에서 셰이프를 설정하려고 시도합니다. 다른 모든 것은 괜찮습니다. <vector>으로 변경하면 앱이 다운됩니다. 나는 ImageViev 응용 프로그램을 설정할 수 있습니다 srcCompat = "드로어 블/사진 아이콘을 모두 확인 @,하지만 난 RadioButton 구성 응용 프로그램으로 설정 한 경우 : srcCompat ="드로어 블/사진 icon_selecton @ 나는 그 오류를 본AppCompat RadioButton 선택기에서 벡터 드로어 블이 충돌 함

`<item android:drawable="@drawable/icon_active" android:state_checked="true"/> 
<item android:drawable="@drawable/icon" android:state_checked="false"/>` 

항목에 대한 사용 API19,하지만 API21 모두 OK!

충돌 코드 :

`Android.Views.InflateException: Binary XML file line #1: 
Error inflating class android.widget.ToggleButton` 

내가 23.4.0.1 라이브러리를 사용합니다.

Main.axml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@drawable/a2" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:windowNoTitle="true" 
    android:id="@+id/container"> 
<RadioGroup 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/radioGroup1" 
    android:orientation="horizontal" 
    android:gravity="center"> 
    <RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/man" 
    android:button="@drawable/woman_selector" 
    android:radius="50dp" 
    android:layout_marginRight="40dp" /> 
    <RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/woman" 
    android:button="@drawable/man_selector" 
    android:radius="50dp" 
    android:layout_marginLeft="40dp" /> 
</RadioGroup> 
</LinearLayout> 

woman_selextor.xml

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/selwoman" android:state_checked="true"/> 
<item android:drawable="@drawable/defwoman" android:state_checked="false"/> 
</selector> 

defwoman.xml (selwoman.xml에만 diffirence 색)

<?xml version="1.0" encoding="UTF-8" ?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" 
       android:id="@+id/shapeBg"> 
      <solid android:color="#B733C6"/>  
      <size android:width="70dp" android:height="70dp"/> 
     </shape> 
    </item> 
    <item> 
    <vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:width="70dp" 
    android:height="70dp" 
    android:viewportWidth="70" 
    android:viewportHeight="70"> 
    <path 
     android:fillColor="#ffffff" 
     android:pathData="M43 45l-6 0 0 -5c6,-1 11,-6 11,-13 0,-7 -6,-13 -13,-13 -7,0 -13,6 -13,13 0,7 
5,12 11,13l0 5 -6 0c-2,0 -2,3 0,3l6 0 0 6c0,2 4,2 4,0l0 -6 6 0c2,0 2,-3 
0,-3zm-18 -18c0,-5 5,-10 10,-10 5,0 10,5 10,10 0,5 -5,10 -10,10 -5,0 -10,-5 
-10,-10z" /> 
</vector> 
    </item> 
</layer-list> 
,

그리고 지원 라이브러리 :

Xamarin.Android.Support.Animated.Vector.Drawable.23.4.0.1 Xamarin.Android.Support.v4.23.4.0.1 Xamarin.Android.Support.v7.AppCompat. 23.4.0.1 Xamarin.Android.Support.Vector.Drawable.23.4.0.1는

나는 새로운 응용 프로그램을 작성하고이 오류를 재현, link to App1.sln archive

안드로이드 5.1이 완벽하게 작동하지만 4.4에 추락했다. 드로어 블 아이템 - 벡터에서 제거하는 경우 아이콘이없는 4.4에서 작동합니다.

+0

전에 벡터처럼 보인다 라디오 버튼이 사용되는 곳에서 완전한 axml을 제공하여 신속하게 재현 할 수 있습니까? –

+0

@ 유리, 내 질문, 기본, 선택기 및 벡터 drawable에 코드를 추가합니다. – Ron

+0

프로젝트에 대한 링크를 제공하는 것이 큰 도움이되었습니다. 문제를 신속하게 재현 할 수 있었습니까 –

답변

0

은 활동 AppCompatActivity에서 파생 확인하고

[Activity (Label = "App1.Droid", MainLauncher = true, Icon = "@drawable/icon")] 
     public class MainActivity : AppCompatActivity 
     { 

      static MainActivity() 
      { 
       AppCompatDelegate.CompatVectorFromResourcesEnabled = true; 
      } 

      protected override void OnCreate (Bundle bundle) 
      { 

당신은 APPCOMPAT에서 파생 된 매니페스트의 테마를 변경해야합니다 정적 생성자를 추가합니다. 당신은 그릴 수

<?xml version="1.0" encoding="UTF-8" ?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" 
      android:id="@+id/shapeBg"> 
     <solid android:color="#fff"/> 
     <size android:width="70dp" android:height="70dp"/> 
    </shape> 
    </item> 
    <item android:drawable="@drawable/woman_path"/> 
</layer-list> 

woman_path.xml와 항목으로 선택기에서

<application android:label="App1.Droid" android:theme="@style/Theme.AppCompat"></application> 

에게 (내가 어둠을 좋아) 벡터를 대체 항목을 다른 테마를 선택할 수 있습니다 당신이 할 수있는

<?xml version="1.0" encoding="UTF-8" ?> 
<vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:width="70dp" 
    android:height="70dp" 
    android:viewportWidth="70" 
    android:viewportHeight="70"> 
    <path 
     android:fillColor="#ffffff" 
     android:pathData="M43 45l-6 0 0 -5c6,-1 11,-6 11,-13 0,-7 -6,-13 -13,-13 -7,0 -13,6 -13,13 0,7 
5,12 11,13l0 5 -6 0c-2,0 -2,3 0,3l6 0 0 6c0,2 4,2 4,0l0 -6 6 0c2,0 2,-3 
0,-3zm-18 -18c0,-5 5,-10 10,-10 5,0 10,5 10,10 0,5 -5,10 -10,10 -5,0 -10,-5 
-10,-10z" /> 
</vector> 
+0

고마워요! 일했다! '정적 MainActivity()' – Ron

관련 문제