vlc for android 主题属性分析
来源:互联网 发布:cn域名续费多少钱 编辑:程序博客网 时间:2024/05/16 17:29
目前在研究vlc for android的代码,对于其中的主题属性有了一些了解,记录如下以便以后查找。
vlc-android\res\values\styles.xml中有如下定义:
<style name="Theme.VLC" parent="Theme.VLC.7"/><style name="Theme.VLC.7" parent="Theme.VLC.Apearance"> <item name="actionBarStyle">@style/ActionBar</item> <item name="windowActionBarOverlay">true</item> <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item></style><style name="Theme.VLC.Apearance" parent="Theme.AppCompat.Light.NoActionBar"> <item name="marginTopContent">50dp</item> ...... <item name="ic_pause">@drawable/ic_pause</item> ......</style>
我们可以看到vlc-android\res\drawable\下面有一个ic_pause.xml,其内容如下:
<?xml version="1.0" encoding="UTF-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/ic_pause_normal" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@drawable/ic_pause_pressed" android:state_focused="true"/> <item android:drawable="@drawable/ic_pause_pressed" android:state_pressed="true"/> <item android:drawable="@drawable/ic_pause_normal"/></selector>因此属性ic_pause其实是一个正常状态和按下状态的暂停图片,这些图片ic_pause_normal.png及ic_pause_pressed.png存在于res的drawable-hdpi、drawable-ldpi、drawable-mdpi、drawable-xhdpi目录下。
其对应的属性定义在vlc-android\res\values\attrs.xml中:
<attr name="ic_pause" format="reference" />
<ImageButton android:id="@+id/header_play_pause" android:layout_width="32dp" android:layout_height="32dp" android:layout_gravity="center" android:layout_marginRight="@dimen/default_margin" android:background="#00000000" android:contentDescription="@string/pause" android:focusable="true" android:scaleType="fitXY" android:src="?attr/ic_pause" android:nextFocusForward="@+id/header_play_pause" android:nextFocusUp="@+id/ml_menu_search" android:nextFocusDown="@id/header_play_pause" android:nextFocusLeft="@id/header_play_pause" android:nextFocusRight="@id/header_play_pause" />
这样就相当于使用了主题中的ic_pause属性,实际就是不同状态下引用哪个图片作为图片按钮的当前图片。
最后别忘了AndroidManifest.xml中给对应的Activity设置主题,如下所示:
<activity android:name=".gui.MainActivity" android:icon="@drawable/icon" android:label="@string/app_name" android:launchMode="singleTask" android:windowSoftInputMode="adjustPan" android:theme="@style/Theme.VLC" > <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /></activity>
如果不设置该Activity的android:theme,运行时将会出现“android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path)”这种错误。
1 0
- vlc for android 主题属性分析
- Vlc-for-android源码分析
- Vlc-for-android源码分析
- Vlc-for-android源码分析
- vlc for android compile
- vlc-for-android编译
- vlc for android
- VLC compile for Android
- vlc for android demo
- vlc-for-android
- vlc-for-android
- vlc-for-android
- vlc-for-android
- VLC Media Player for Android
- VLC for Android的编译
- Vlc for Android 全面阐述
- VLC for android 编译使用
- Vlc For Android问题总结
- 接口型模式之Bridge(桥接)模式
- ONOS 系统组件介绍
- 有关树的几个经典问题
- 浅谈浏览器http的缓存机制
- JavaScript、Ajax与JQuery的关系
- vlc for android 主题属性分析
- Zookeeper的PHP实践
- 如何才能不崩溃 4: Threading
- 顺序读写文件的实验
- 双亲委派模型
- 图 谱 马尔可夫
- 排序(1) 初级排序
- Git常用命令学习
- 如何才能不崩溃 5: Threading, part 2