2017-12-24 7 views
0

나는 안드로이드를 처음 접하기 때문에 활동, 조각 및 기타 물건을 가지고 노는 중이었습니다. 알림 테마 변경 대화 상자 크기

내 최종 목표입니다 :

enter image description here

현재 시나리오 :이와

enter image description here enter image description here

문제는 내가 지금 할 때, 그래서 match_parent 내 layout_width를 설정 한 것입니다 대화 상자가 나타나면 자체가 wrap_content에 따라 설정되므로 자식 크기에 따라 대화 상자가 표시됩니다. 너비로 설정합니다.

내가 원하는 것은 대화 상자가 전체 길이가되도록하는 것입니다. 너비가 현명하다.

내가 시도하는 것 : this answer

은 기본적으로 내가 테마를 무시할 것이라고 생각하고 수동으로 폭을 추가합니다.

<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> 

; 그것은 내 애플 리케이션을 추락시키고있다.

내 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" /> 

질문 내가 어떻게 크기 수정을해야합니까이며 어떻게 내 대화 테마가 제대로 설정하는 사용자 정의합니까?

P.s : 이것은 대화 상자가 아니라 활동입니다. 대화 테마를 사용했습니다. 이와 XML을 대체하여

답변

0

확인,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/dialogParent1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#ffff" 
    android:orientation="vertical" 
    android:padding="10dp"> 

    <RelativeLayout 
     android:id="@+id/dialogParent2" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/dialogThumnbnail" 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:background="@mipmap/ic_launcher" 
      android:contentDescription="@string/app_name" /> 

     <TextView 
      android:id="@+id/dialogTextview" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_marginHorizontal="10dp" 
      android:layout_toLeftOf="@+id/dialogControl" 
      android:layout_toRightOf="@+id/dialogThumnbnail" 
      android:ellipsize="marquee" 
      android:focusableInTouchMode="true" 
      android:freezesText="true" 
      android:gravity="center" 
      android:marqueeRepeatLimit="marquee_forever" 
      android:maxLines="2" 
      android:scrollHorizontally="true" /> 

     <ToggleButton 
      android:id="@+id/dialogControl" 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_gravity="right" 
      android:background="@mipmap/ic_launcher" 
      android:text="" 
      android:textOff="" 
      android:textOn="" /> 
    </RelativeLayout> 

    <android.support.v4.widget.Space 
     android:layout_width="match_parent" 
     android:layout_height="20dp" /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <SeekBar 
      android:id="@+id/dialogSeekbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_toLeftOf="@+id/tv1" /> 

     <TextView 
      android:id="@+id/tv1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:text="@string/app_name" 
      android:textSize="10sp" 
      android:textStyle="bold" /> 
    </RelativeLayout> 

</LinearLayout> 

나는이 확실히 작동합니다 생각합니다.