1. 程式人生 > >Android自定義Dialog大小控制

Android自定義Dialog大小控制

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="141dp"
    android:orientation="vertical" >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="92dp"
        android:background="@drawable/dialogbackground"
        android:gravity="center"
        android:orientation="vertical" >


        <TextView
            android:id="@+id/dialog_tips_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:lineSpacingExtra="3dp"
            android:lineSpacingMultiplier="1.2"
            android:textColor="#333333"
            android:textSize="15sp"
            android:visibility="gone" />


        <TextView
            android:id="@+id/dialog_content_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:lineSpacingExtra="3dp"
            android:lineSpacingMultiplier="1.2"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:text="@string/my_bank_delete_dialog"<!--這裡是提示文字,可以在程式碼中更改-->
            android:layout_marginTop="3dp" 
            android:textColor="#333333"  
            android:textSize="15sp" />  
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:gravity="center"
        android:orientation="horizontal" >


        <Button
            android:id="@+id/fail"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/dialogsuccess_bg"
            android:gravity="center"
            android:text="取消"
            android:textColor="#007aff"
            android:textSize="17sp" />


        <Button
            android:id="@+id/success"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/dialogerror"
            android:gravity="center"
            android:text="確定"  
            android:textColor="#007aff"
            android:textSize="17sp" />
    </LinearLayout>
</LinearLayout>