Android Activity为对话框黑色边框

时间:2012-11-07 18:15:16

标签: android android-dialog

我有对话活动,我喜欢的所有节目。但我对它们周围的框架有问题。就像这里一样。

enter image description here

我的活动:

public class AlarmAlert extends Activity implements Alarms.AlarmSettings {



    @Override
        protected void onCreate(Bundle icicle) {
            super.onCreate(icicle);

            AlarmAlertWakeLock.acquire(this);

            /*
             * FIXME Intentionally verbose: always log this until we've fully
             * debugged the app failing to start up
             */
            Log.v("AlarmAlert.onCreate()");
            DigitalClock dc = (DigitalClock) findViewById(R.id.digitalClock1);

            mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);

            Intent i = getIntent();
            mAlarmId = i.getIntExtra(Alarms.ID, -1);

            Alarms.getAlarm(getContentResolver(), this, mAlarmId);

            mKlaxon = new AlarmKlaxon();
            mKlaxon.postPlay(this, mAlarmId);

            /* Set the title from the passed in label */
            setTitleFromIntent(i);

            /*
             * allow next alarm to trigger while this activity is active
             */
            Alarms.disableSnoozeAlert(AlarmAlert.this);
            Alarms.disableAlert(AlarmAlert.this, mAlarmId);
            Alarms.setNextAlert(this);

            mKlaxon.setKillerCallback(new AlarmKlaxon.KillerCallback() {
                public void onKilled() {
                    if (Log.LOGV)
                        Log.v("onKilled()");
                    updateSilencedText();

                    /* don't allow snooze */
                    mSnoozeButton.setEnabled(false);
                    dismiss();
                    mState = KILLED;
                }
            });

            updateLayout();

            SharedPreferences settings = getSharedPreferences(
                    AlarmClock.PREFERENCES, 0);
            if (settings.getBoolean(AlarmClock.PREF_SHAKE_SNOOZE, true)) {
                mShakeListener = new ShakeListener(this);
                mShakeListener
                        .setOnShakeListener(new ShakeListener.OnShakeListener() {
                            public void onShake() {
                                snooze();
                                if (mCaptchaSnooze == 0)
                                    finish();
                            }
                        });
            }
        }

        private void setTitleFromIntent(Intent i) {
            mLabel = i.getStringExtra(Alarms.LABEL);
            if (mLabel == null || mLabel.length() == 0) {
                mLabel = getString(R.string.default_label);
            }
            setTitle(mLabel);
        }

        private void updateSilencedText() {
            TextView silenced = (TextView) findViewById(R.id.silencedText);
            silenced.setText(getString(R.string.alarm_alert_alert_silenced,
                    mDuration / 1000 * 60));
            silenced.setVisibility(View.VISIBLE);
        }

        private void updateLayout() {
            setContentView(R.layout.alarm_alert);

我的alert_alarm.xml(对话框)。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="327dp"
    android:layout_height="295dp"
    android:background="@drawable/alertbg"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/silencedText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingBottom="2dp"
        android:paddingTop="2dp"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@color/ltgrey"
        android:visibility="gone" />

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="230dp"
        android:gravity="center_horizontal" >

        <Button
            android:id="@+id/snooze"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="25dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/teesstt"
            android:text="@string/snooze_button"
            android:textColor="#fff"
            android:textSize="25dp"
            android:visibility="visible" />

        <Button
            android:id="@+id/dismiss"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="25dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/teesstt"
            android:text="@string/dismiss_button"
            android:textColor="#fff"
            android:textSize="25dp"
            android:visibility="visible" />
    </RelativeLayout>
    <TextView
        android:id="@+id/tvDD"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/tvDate"
        android:layout_alignLeft="@+id/tvDate"
        android:text="Medium Text"
        android:textSize="20dp"
        android:textColor="#a6a6a6" />
    <TextView
        android:id="@+id/tvDate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/relativeLayout1"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="55dp"
        android:layout_marginLeft="30dp"
        android:text="Medium Text"
        android:textSize="25dp"
        android:textColor="#a6a6a6" />


    <com.boxclocks.android.alarmclock.dc
        android:id="@+id/digitalClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="58dp"
        android:text="DigitalClock"
        android:textColor="#a6a6a6"
        android:textSize="70dp" />

</RelativeLayout>

如何删除边框。

2 个答案:

答案 0 :(得分:3)

dialog.getWindow()setBackgroundDrawableResource(android.R.color.transparent);

Dialog

答案 1 :(得分:1)

您有两种选择。您可以将活动的主题设置为

  Theme_Translucent_NoTitleBar

或者您必须创建一个新主题并使用此处指定的自定义九个补丁加载

How to remove border from Dialog?