【问题标题】:Android Activity as dialog black borderAndroid Activity 作为对话框黑色边框
【发布时间】:2013-06-21 16:59:05
【问题描述】:

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

我的活动:

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>

如何去除边框。

【问题讨论】:

    标签: android android-dialog


    【解决方案1】:

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

    Dialog

    【讨论】:

    • 感谢您的回答,这对我很有帮助。
    • 如果你的活动是对话,它应该只是getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    【解决方案2】:

    你有两个选择。您可以将 Activity 的主题设置为

      Theme_Translucent_NoTitleBar
    

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

    How to remove border from Dialog?

    【讨论】:

      猜你喜欢
      • 2010-12-31
      • 2015-11-16
      • 2010-12-25
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      • 2011-02-08
      • 1970-01-01
      • 2013-01-04
      相关资源
      最近更新 更多