2011-12-15 94 views
2

我已经完成了我的应用程序的逻辑编码,其中包含一个GridView,几个TextViews和几个对话框。Android的预定义样式和主题

我现在希望对这些视图进行设计,因为默认主题有点难看。

我已经看了一下提供的Android主题,并尝试了其中的一些,但他们并没有真正提供很多。 因此,我想知道是否有任何资源可以让我快速应用预定义的thene,然后我可以相应地调整它? 在几个时尚主题之间切换以获取创意并调整它们的能力将非常有益,因为我不是最具有图形界面的主题。

谢谢

+0

你要什么改变来使控制看起来不那么丑吗?如果足够,您可以在布局XML中编辑textview大小,字体和颜色。 – georgiecasey

+0

我想我可以做到这一点,但我希望可能有一些我可以用作基础的快速适配主题列表。默认的Android主题不是很好 – DJ180

回答

2

在这里,我做了不同的样式对话框。我首先定义一个形状,其给出为渐变填充的背景和圆形边缘:

filled_roundededges_box.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 
    <gradient 
     android:startColor="#353535" 
     android:endColor="#222222" 
     android:angle="90" /> 
<stroke android:width="2dp" android:color="#808080"/> 
<corners android:radius="5dp" /> 
<padding android:left="10dp" android:top="10dp" 
    android:right="10dp" android:bottom="10dp" /> 
</shape> 

我然后使用该形状创建一个样式:

styles.xml:

<style name="AppCustomDialog" parent="android:style/Theme.Dialog"> 
    <item name="android:windowBackground">@drawable/filled_roundededges_box</item> 
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowSoftInputMode">stateVisible</item> 
</style> 

最后,我将这种风格应用于我的按钮:

<ImageButton 
     android:id="@+id/addedit_btnPrev" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical|right" 
     android:src="@drawable/left" 
     style="@style/App_ButtonStyle" /> 

或者你可以申请风格为题材的谁使用应用程序:

<application 
    android:icon="@drawable/ic_launcher_noteit1" 
    android:label="@string/app_name" 
    android:theme="@style/App_Theme" 
    android:name="NoteItApplication" 
    android:debuggable="true"> 
+0

谢谢,我会试试看。我认为ImageButton中的样式名称不正确? – DJ180

+0

是的,对不起。但我希望你能得到这个主意。如果你想要更多的灵活性,请看看http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html,我发现它很有趣。 –