Android 입문 스타일 과 Theme 용법 인 스 턴 스 분석
1.Theme 는 창 단 계 를 대상 으로 창 스타일 을 바 꿉 니 다.
2.Style 은 창 요소 단 계 를 대상 으로 지정 한 컨트롤 이나 Layout 스타일 을 변경 합 니 다.
Android 시스템 의 themes.xml 과 style.xml(/base/core/res/res/values/에 있 음)은 시스템 이 정의 한 style 을 많이 포함 하고 있 습 니 다.그 중에서 적당 한 것 을 골 라 서 수정 을 계승 하 는 것 을 권장 합 니 다.아래 의 이 코드 속성 은 Themes 에서 흔히 볼 수 있 는 것 으로 Android 시스템 자체 의 themes.xml 에서 기원 합 니 다.
<!-- Window attributes -->
<item name="windowBackground">@android:drawable/screen_background_dark</item>
<item name="windowFrame">@null</item>
<item name="windowNoTitle">false</item>
<item name="windowFullscreen">false</item>
<item name="windowIsFloating">false</item>
<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
<item name="windowTitleStyle">@android:style/WindowTitle</item>
<item name="windowTitleSize">25dip</item>
<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>
컨트롤 의 Style 디자인 은 범위 가 넓 습 니 다.Eclipse 의 Android 컨트롤 속성 편집기[Properties]를 보면 어떤 항목 이 있 는 지 대충 알 수 있 습 니 다.Android 에 내 장 된 style.xml 도 모든 컨트롤 의 기본 스타일 을 정의 할 뿐 입 니 다.그러나 컨트롤 의 style 은 크게 바 꾸 는 것 을 권장 하지 않 습 니 다.오래 볼 수 있 는 style 은 사용자 로 하여 금 소프트웨어 를 장시간 사용 하 게 할 수 있 습 니 다.또한,컨트롤 의 Style 은 9.png 를 많이 사용 합 니 다.9.png 를 배우 면/base/core/res/res/drawable-hdpi 에 가 봐 야 합 니 다.시스템 에 내 장 된 9.png 가 많 습 니 다.메모:안 드 로 이 드 의 Style 과 Theme 를 연구 하기 위해 안 드 로 이 드 의 base.git 를 다운로드 하 는 것 을 강력 히 권장 합 니 다!
먼저 본 고의 프로그램의 효 과 를 살 펴 보 자.다음 그림 과 같다.
이 프로그램의 themes.xml 코드 는 다음 과 같 습 니 다.Window Title 을 사용자 정의 하 였 습 니 다.
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Android Theme.Light, /base/core/res/res/values/themes.xml -->
<style name="Theme" parent="android:Theme.Light">
<item name="android:windowFullscreen">true</item>
<item name="android:windowTitleSize">60dip</item>
<item name="android:windowTitleStyle">@style/WindowTitle</item>
</style>
<style name="WindowTitle" parent="android:WindowTitle">
<item name="android:singleLine">true</item>
<item name="android:shadowColor">#BB000000</item>
<item name="android:shadowRadius">2.75</item>
</style>
</resources>
Activity 에 theme 를 사용 하려 면 코드 setTheme(R.style.Theme)을 사용 하거나 Application Manifest 에 다음 과 같이 설정 하 십시오.본 프로그램의 styles.xml 코드 는 다음 과 같 습 니 다.background 는 기본적으로 9.png 를 사용 하고 xml 는/base/core/res/res/drawable/아래 에 정의 합 니 다.
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="TextView">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#008</item>
<item name="android:shadowColor">@android:color/black</item>
<item name="android:shadowRadius">2.0</item>
</style>
<style name="EditText">
<item name="android:shadowColor">@android:color/black</item>
<item name="android:shadowRadius">1.0</item>
<item name="android:background">@android:drawable/btn_default</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>
<style name="Button">
<item name="android:background">@android:drawable/edit_text</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>
</resources>
main.xml 코드 는 다음 과 같 습 니 다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
style="@style/TextView" />
<EditText android:id="@+id/EditText01" android:layout_height="wrap_content"
style="@style/EditText" android:layout_width="fill_parent"
android:text=" Button EditText"></EditText>
<EditText android:id="@+id/EditText02" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text=" EditText"></EditText>
<Button android:id="@+id/Button01" android:layout_height="wrap_content"
style="@style/Button" android:layout_width="fill_parent" android:text=" EditText Button"></Button>
</LinearLayout>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Bitrise에서 배포 어플리케이션 설정 테스트하기이 글은 Bitrise 광고 달력의 23일째 글입니다. 자체 또는 당사 등에서 Bitrise 구축 서비스를 사용합니다. 그나저나 며칠 전 Bitrise User Group Meetup #3에서 아래 슬라이드를 발표했...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.