이 클래스는 PopupWindow
입니다. 나는 @android:color/transparent
에 클래스의 배경을 설정하고 내용의 대한 다음과 같은 레이아웃을 사용투명 PopupWindow의 레이아웃에 사용 된 스타일이 적용된 배경이
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tips_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dip"
android:orientation="horizontal"
style="?Tips_Background" >
<TextView
android:id="@+id/textInfo"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/register_termsandconditions"
style="?TextAppearance_Footer" />
<ImageButton
android:id="@+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="0dip"
android:layout_gravity="top|right"
android:src="@drawable/btn_dialog_normal"
style="@style/App_ImageButtonStyle" />
</LinearLayout>
아이디어과 같이 팝업을 얻을 수 있습니다 :
내가 이것을 달성하기 위해 사용하는 스타일 효과는 다음과 같습니다 :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:visible="false">
<gradient
android:startColor="@color/trademark_dark"
android:endColor="@color/trademark_darkest"
android:angle="90" />
<stroke android:width="2dp" android:color="#AAAAAA" />
<corners android:radius="10dp" />
<padding
android:left="8dp"
android:top="8dp"
android:right="8dp"
android:bottom="8dp" />
</shape>
예상대로 작동합니다 배경이 전혀 효과가없는 것처럼 투명하게 투명합니다.
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/NI_AppTheme.Trademark"
android:name="NApplication">
<activity android:name="LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
....
LoginActivity
나는이 문제에 직면하고있어있는 유일한 활동 :
내가 사용하는 모든 응용 프로그램에 적용이 스타일을 포함하는 테마를 가지고있다. 나는 무엇을 놓칠 수 있 었는가?
UPDATE :
@imran 칸 작동에 의해 설명 된 솔루션입니다. 그러나 테마가 배경에 따라 달라 지므로이 값은 직접 하드 코드 된 참조가 아닌 테마 속성을 통해 참조해야합니다.
<style name="NI_AppTheme.Trademark">
<item name="Tips_Background">@drawable/application_tips_trademark</item>
</style>
을 그리고 레이아웃 'android:background="?Tips_Background"
을 설정하지만 다음과 같은 스택 추적과 함께 응용 프로그램 충돌 : 나는 시도 당김 고해상도 /에서
06-25 21:09:36.518: E/AndroidRuntime(874): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01002e a=-1}
06-25 21:09:36.518: E/AndroidRuntime(874): at android.content.res.Resources.loadDrawable(Resources.java:1897)
06-25 21:09:36.518: E/AndroidRuntime(874): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-25 21:09:36.518: E/AndroidRuntime(874): at android.view.View.<init>(View.java:2785)
06-25 21:09:36.518: E/AndroidRuntime(874): at android.view.ViewGroup.<init>(ViewGroup.java:385)
06-25 21:09:36.518: E/AndroidRuntime(874): at android.widget.LinearLayout.<init>(LinearLayout.java:174)
06-25 21:09:36.518: E/AndroidRuntime(874): at android.widget.LinearLayout.<init>(LinearLayout.java:170)
매니쉬 셰이프 –
대신 셀렉터를 사용하여 android : background = "@ drawable/Tips_Background"를 사용하고 모양 xml을 res/drawable에 넣으십시오. –