Android 自定义对话框样式

标签 android xml

我在做什么::输出是一个自定义对话框


我目前的输出::

enter image description here

我的代码::

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#252525"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ProgressBar
            android:id="@+id/prgBar"
            android:layout_width="40dp"
            android:layout_height="40dp" />

        <TextView
            android:id="@+id/txtMessage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center|center_horizontal"
            android:text="Loading.."
            android:textColor="#ffffff" />
    </LinearLayout>

    <View
        android:id="@+id/view1"
        style="@style/Divider"
        android:layout_below="@+id/linearLayout"
        android:layout_gravity="center|center_horizontal" />

    <Button
        android:id="@+id/dlgCancelBtn"
        style="@style/ButtonText"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_gravity="center|center_horizontal"
        android:layout_below="@+id/view1"
        android:background="@drawable/my_button" />

</RelativeLayout>

我正在尝试做什么::

enter image description here

{编辑}

styles.xml

<resources>

    <style name="Divider">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">1dp</item>
        <item name="android:background">#acacac</item>
    </style>

    <style name="ButtonText">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:gravity">center</item>
        <item name="android:layout_margin">3dp</item>
        <item name="android:textSize">14dp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:shadowColor">#000000</item>
        <item name="android:shadowDx">1</item>
        <item name="android:shadowDy">1</item>
        <item name="android:shadowRadius">2</item>
     </style>
    <color name="buttonbackground">#252525</color>
    <color name="buttononclicked">#00aeef</color>


    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.



    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.



        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

my_button.xml(这是可绘制的)

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@color/buttononclicked" /> 
    <item android:drawable="@color/buttononclicked" />
</selector>

如何修改我的 xml 以获得我的结果

最佳答案

尝试改变这个

<item name="android:layout_margin">3dp</item>

对此

<item name="android:layout_margin">0dp</item>

在你的 styles.xml 中

关于Android 自定义对话框样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21801331/

相关文章:

android - BillingClient.BillingClientStateListener.onBillingSetupFinished 被多次调用

android - 找出 Android 蓝牙 LE GATT 配置文件

c# - 如何在 c# .net CF 3.5 中使用 XmlDocument 向 xml 添加属性

xml - PHP 解析错误 - 意外的 T_STRING

java - 使用 Java 解析 XML 文件(DOM 解析器)

android eclipse无法执行dex java堆空间错误

android - 使用 GoogleServices 插件时忽略 Gradle ArchivesBaseName

xml - XSLT - 选择没有属性的节点

python - Odoo 10 在 XML 中使用配置值(存储在 ir.values 中)

Android native 构建错误可能不安全 [-Werror,-Wformat-security]