이 간단한 대화 조각이 반투명하게하는 방법 :나는이 간단한 대화 반투명 만들려고 노력하고
class TestDialog extends SherlockDialogFragment
{
public TestDialog()
{
super();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceStateBundle)
{
AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater1 = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder1.setView(inflater1.inflate(R.layout.dlg_test, null))
// Add action buttons
.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int id)
{
// sign in the user ...
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int id)
{
}
});
return builder1.create();
}
}
레이아웃은 다음과 같다 : 나는 모든 것을 시도
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"
android:hint="User name" />
</LinearLayout>
을, 선형 레이아웃의 배경 drawable으로 투명한 .png를 사용하는 것에서 알파 필드를 0.5로 설정하는 것, Drawable으로 0과 같은 색을 사용하는 것까지. 나는 그 다이얼로그를 반투명하게 만들 수 없다. 나는 그것이 가능할지라도 모른다. 내가 만들고자하는 것은 다음 이미지의 패널과 같은 대화 상자입니다 : . 감사합니다. . 주 1 : 필요한 최소 sdk는 버전 8이며 대상은 최신 (실제로는 v17)입니다.
: 관련 질문에 대한 내 대답에
링크 SDK 버전. 1.6 대화 상자는 기본적으로 반투명하지만'AlertDialog.Builder (Context context, int theme)'를 시도합니다. 여기서 theme은'android.R.style.Theme_Dialog '입니다. – techiServices
XML에서'android : background = "# 4000"'같은 것을 사용해 보셨나요? (# 4000은 ARGB_4444 색상 공간 임). – techiServices
둘 다 시도했지만 작동하지 않았습니다. –