Android自定义对话框样式

时间:2014-02-15 17:53:27

标签: android xml

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


我目前的输出 ::

enter image description here

Mycode ::

<?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以获取结果

1 个答案:

答案 0 :(得分:1)

尝试更改此

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

到这个

<item name="android:layout_margin">0dp</item>
你的styles.xml中的