IT Share you

Android 4.0 하위 제목 (섹션) 라벨 스타일링

shareyou 2020. 11. 20. 17:19
반응형

Android 4.0 하위 제목 (섹션) 라벨 스타일링


그래서 저는 ICS 에 대한 Android Dev Design 사이트보고 있었고 모든 앱에 다음과 같은 자막 / 섹션 헤더가 있습니다.

ICS 섹션 헤더

이렇게 보이는 라벨을 만들기 위해 커스텀 스타일링을 아는 사람이 있는지 궁금합니다. Android SDK에서 이와 같은 레이블 뷰를 찾을 수 없지만 이러한 모양이 정말 마음에 듭니다.

미리 감사드립니다!


그래서 이것은 내가 사용한 결과입니다.

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="sectionHeader" parent="android:Widget.Holo.Light.TextView">
        <item name="android:drawableBottom">@drawable/section_header</item>
        <item name="android:drawablePadding">4dp</item>
        <item name="android:layout_marginTop">8dp</item>
        <item name="android:paddingLeft">4dp</item>
        <item name="android:textAllCaps">true</item>
        <item name="android:textColor">@color/emphasis</item>
        <item name="android:textSize">14sp</item>
    </style>
</resources>

@ drawable / section_header는 다음과 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <size android:width="1000dp" android:height="2dp" />
    <solid 
        android:color="@color/emphasis"/>
</shape>

그리고 @color :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="emphasis">#31b6e7</color>
    <color name="bg_gray">#cecbce</color>
</resources>

Brandon의 말이 맞습니다. 파란색 스타일을 얻으려면 지금은 사용자 지정 작업을 수행해야합니다. 새 디자인 가이드 전체에 적용되므로 다소 실망 스럽습니다.

안타깝게도 Widget.Holo.Light.TextView.ListSeparator사용자 정의 스타일은 비공개이기 때문에 부모로 참조 할 수 없습니다 .

그러나 회색 선에만 관심이 있다면 스톡 Android 스타일 인라인을 사용할 수 있습니다.

style="?android:attr/listSeparatorTextViewStyle"

이것은 최소한 회색 선, 모든 대문자 스타일로 이동합니다.

여기에 이미지 설명 입력

Brandon의 대답은 사용자 정의 파란색 스타일을 제공합니다.

참고로, List Separators에 대해 현재 (v15) Android 스타일에서 정확히 하위 클래스를 지정하려는 경우 Android에서 사용되는 결합 된 스타일 Widget.TextView.ListSeparatorWidget.Holo.Light.TextView.ListSeparator새 스타일로 복사 할 수있는 스타일은 다음과 같습니다.

<item name="android:background">@drawable/list_section_divider_holo_light</item>
<item name="android:textAllCaps">true</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">?android:textColorSecondary</item>
<item name="android:textSize">14sp</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">8dip</item>

드로어 블은 개인용이므로 자신의 디렉터리에 복사해야합니다.


정확히 어떤 스타일인지 잘 모르겠지만 환경 설정 앱도이를 사용합니다 (또는 매우 유사한 것). 섹션 헤더입니다. 또한 TextField는 textAllCapstrue로 설정되어 있습니다. textAllCaps를 찾으면 SDK의 리소스 폴더에서 찾을 수 있습니다. :)


선을 그리려면 높이가 tu 1dp 정도로 설정된 View를 사용하십시오. 배경 속성을 사용하여 색상을 설정할 수 있습니다.

참고 URL : https://stackoverflow.com/questions/10020466/android-4-0-sub-title-section-label-styling

반응형