Ich bin neu bei Android, also spielte ich mit Aktivität, Fragmente und andere Sachen.Ändern der Warnung Thema Dialoggröße
Das ist mein Endziel:
Aktuelle Szenario:
Problem dabei ist, dass ich meine layout_width zu match_parent
so eingestellt haben, jetzt, wenn die Der Dialog erscheint, er richtet sich nach wrap_content
, also abhängig von den Kindgrößen, die der Dialog bekommt in der Breite einstellen.
Was ich will, ist für den Dialog in voller Länge; Breite weise. Was
Ich habe versucht: this answer
Im Grunde dachte ich, das Thema außer Kraft setzen würde und seine Breite manuell hinzufügen.
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:width">@dimen/dialog_width</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>
dimens.xml
<dimen name="dialog_width">@dimen/match_parent</dimen>
attribs.xml
<resources>
<item name="match_parent" type="dimen">-1</item>
<item name="wrap_content" type="dimen">-2</item>
</resources>
Dies funktioniert nicht; Es bringt meine App zum Absturz.
Mein xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffff"
android:id="@+id/dialogParent1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dialogParent2"
android:orientation="horizontal">
<ImageView
android:layout_weight="1"
android:contentDescription="@string/contains_song_thumbnail"
android:layout_width="0dp"
android:layout_height="40dp"
android:id="@+id/dialogThumnbnail"
android:layout_margin="10dp"
android:background="@mipmap/ic_music_note_black_24dp"
/>
<TextView
android:layout_weight="6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:id="@+id/dialogTextview"
android:scrollHorizontally="true"
android:freezesText="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
/>
<ToggleButton
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text=""
android:textOff=""
android:layout_margin="5dp"
android:id="@+id/dialogControl"
android:background="@drawable/ic_play_pause_small"
android:textOn="" />
</LinearLayout>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<SeekBar
android:id="@+id/dialogSeekbar"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="10sp"
android:textStyle="bold"
android:gravity="center"
/>
</LinearLayout>
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="20dp" />
Frage ist, wie mache ich die Größe fix und wie kann ich die mein Dialog Thema richtig eingestellt?
Ps.S: Dies ist kein Dialog, aber es ist eine Aktivität, ich habe gerade das Dialogfeld Thema verwendet.