2

我已经完成了我的应用程序的逻辑编码,其中包含一个 GridView、一些 TextView 和一些对话框。

我现在希望为这些视图设置样式,因为默认主题有点难看。

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

谢谢

4

1 回答 1

2

在这里,我如何以不同的方式设置我的对话框。我首先定义了一个形状,它给出了一个渐变填充背景和圆角边缘:

填充的_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>

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

样式.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" />

或者,您可以使用以下方式将样式作为主题应用于 who 应用程序:

<application
    android:icon="@drawable/ic_launcher_noteit1"
    android:label="@string/app_name" 
    android:theme="@style/App_Theme"
    android:name="NoteItApplication" 
    android:debuggable="true">
于 2011-12-15T04:25:26.890 回答