Android 的预定义样式和主题

发布于 2024-12-21 07:45:53 字数 248 浏览 4 评论 0原文

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

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

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

谢谢

I have finished coding the logic of my application, which contains a GridView, a few TextViews and a few dialogs.

I now wish to style these views, as the default theme is somewhat ugly.

I've had a look at the provided Android themes, and tried out a few of them but they didn't really offer much.
Therefore, I'm wondering if there are any resources available that would allow me to quickly apply a pre-defined thene and I could then tweak it accordingly?
The ability to switch between a few stylish themes to get ideas and tweak them would be very beneficial as I am not the most graphical-minded.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2024-12-28 07:45:53

下面是我如何以不同的方式设计我的对话框。我首先定义一个形状,它提供渐变填充背景和圆角边缘:

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" />

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

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

Here what I do to style my dialogs differently. I first define a shape which gives be a gradient filled background and rounded edges:

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>

I then create a style using this 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>

Finally I apply this style to my button:

<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" />

Alternatively you can apply the style as a theme to the who app using:

<application
    android:icon="@drawable/ic_launcher_noteit1"
    android:label="@string/app_name" 
    android:theme="@style/App_Theme"
    android:name="NoteItApplication" 
    android:debuggable="true">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文