2017-12-06 3 views
0

그들은 그 다음과 같습니다 값은 다음과 같은 내용으로 폴더에맞춤 스타일을 만드는 방법은 무엇입니까? 내 axml 파일에 여러보기 위젯이

<View 
    android:layout_width="fill_parent" 
    android:layout_height="2dp" 
    android:layout_marginTop="1dp" 
    android:layout_marginBottom="5dp" 
    android:background="#c0c0c0" /> 

내가 코드를 반복하고 싶지 않아 그래서 난 styles.xml 파일을 만든 :

<View 
    android:style="@style/HorizontalLine" 
/> 

을하지만 그것은 작동하지 않습니다

<resources> 
    <style name="HorizontalLine"> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:layout_height">2dp</item> 
     <item name="android:layout_marginTop">1dp</item> 
     <item name="marginBottom">5dp</item> 
     <item name="android:background">#c0c0c0</item> 
    </style> 
</resources> 
은 지금은 그런 내보기에 스타일을 참조하는 데 노력하고있어. 나는 스타일을 창조하기 위해 인터넷에서 모든 것을 시도했다. 내가 틀린 곳?

+1

XML로 볼 높이와 폭을 제공 또한 – YoLo

+0

그것의 같은 ... – proffstack

+1

<보기 안드로이드 시도 /> 시도해보십시오. – YoLo

답변

1

Here is about how to use style in Xamarin.Android

이 당신의 코드를 바꿉니다 :

styles.xml을 : 그것은 컴파일러에 의해 인식 할 수

<resources> 
    <style name="HorizontalLine"> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:layout_height">2dp</item> 
     <item name="android:layout_marginTop">1dp</item> 
     <item name="android:layout_marginBottom">5dp</item> 
     <item name="android:background">#c0c0c0</item> 
    </style> 
</resources> 

<item name="marginBottom">5dp</item>.

layout.xml

:

<View 
    style="@style/HorizontalLine" 
/> 

style=android:style= 교체, 해당 링크에서 볼 수 있습니다. layout_width = "fill_parent" 안드로이드 : layout_height = "20dp" 안드로이드 : 스타일 = "@ 스타일/HorizontalLine으로"

관련 문제