AlertDialog 너비와 높이를 xml로 변경하는 작업이 있습니다. 스타일이 만들어지기를 바래서 쉽게 사용할 수 있습니다. 그리고 AlertDialog 스타일의 단추도 변경해야합니다. target.Thank 당신은 매우 감사 얻을 수 있습니다. PS, 나는 더 나은 변화 XML에 의해 목표를 달성하는 것입니다.Android : AlertDialog 너비와 높이 및 AlertDialog 스타일의 버튼을 어떻게 설정합니까?
7
A
답변
18
를 XML 레이아웃
1)=======>
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.setTitle("Title");
alertDialog = builder.create();
alertDialog.show();
alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
(or)
alertDialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(alertDialog.getWindow().getAttributes());
lp.width = 150;
lp.height = 500;
lp.x=-170;
lp.y=100;
alertDialog.getWindow().setAttributes(lp);
당신이 원하는 경우를 사용하여 두 가지 방법 1) 프로그래밍 방식 2)이 있습니다 Alert dialog
과 같이 표시 할 레이아웃을 표시합니다. this
2)========>
choose.xml
<TextView
android:id="@+id/img"
android:layout_width="wrap_content"
android:text="@string/choose"
android:textSize="25dp"
android:textColor="#fff"
android:layout_height="50dp"/>
<TableLayout android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical">
<TableRow
android:id="@+id/tr1"
android:orientation="horizontal"
android:layout_margin="10dp">
<ImageView
android:contentDescription="@string/phone"
android:src="@drawable/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/phnText"
android:layout_width="wrap_content"
android:text="@string/phone"
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:textColor="#000"
android:layout_height="50dp"/>
</TableRow>
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#FF000000" />
<TableRow
android:id="@+id/tr2"
android:orientation="horizontal"
android:layout_margin="10dp">
<ImageView
android:contentDescription="@string/sms"
android:src="@drawable/sms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/smsText"
android:layout_width="wrap_content"
android:text="@string/sms"
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:textColor="#000"
android:layout_height="50dp"/>
</TableRow>
</TableLayout>
</LinearLayout>
화면이 팝업처럼
아래private void showPopUp()
{
final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("");
LayoutInflater inflater = getLayoutInflater();
final View checkboxLayout = inflater.inflate(R.layout.choose, null);
helpBuilder.setView(checkboxLayout);
final AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
TableRow tablerowPhone = (TableRow)checkboxLayout.findViewById(R.id.tr1);
TableRow tablerowSms = (TableRow)checkboxLayout.findViewById(R.id.tr2);
tablerowPhone.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
helpDialog.dismiss();
Uri callUri = Uri.parse("tel:" + listview_array[4]);
Intent intent = new Intent(Intent.ACTION_CALL, callUri);
startActivity(intent);
}
});
tablerowSms.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
helpDialog.dismiss();
Uri smsUri = Uri.parse("sms:" + listview_array[4]);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
startActivity(intent);
}
});
}
전화 당신이 원하는이 showPopUp()
방법 등이있다. 당신이
+0
많이 고마워요.이 방법은 가능하지만 XML 파일로 처리하고 싶습니다. 구성하고 싶습니다. 내 application.do XML 파일을 XML로 할 수있는 방법이 있나요? 계속해서 다시 한번 감사드립니다. – oldfox3721
1
이 시도 XML 파일의 레이아웃에 높이와 폭을 설정할 수 있도록,이
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.setTitle("Title");
alertDialog = builder.create();
alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
alertDialog.show();
관련 문제
- 1. Android - alertdialog 버튼을 클릭하면보기가 변경됩니다.
- 2. Android AlertDialog 버튼 클릭
- 3. AlertDialog 버튼을 비활성화 하시겠습니까?
- 4. AlertDialog 후의 AlertDialog
- 5. Android 서비스 및 AlertDialog 활동
- 6. Android Fragmentation AlertDialog 문제?
- 7. Android AlertDialog 기본 방향
- 8. Android AlertDialog SetText
- 9. Android alertdialog 테마
- 10. Android AlertDialog 사용
- 11. Android : AsyncTask의 AlertDialog 오류
- 12. Android AlertDialog 질문
- 13. 정의에 AlertDialog
- 14. AlertDialog 버튼을 두 번 클릭해야합니다.
- 15. 안드로이드의 AlertDialog
- 16. Android 중첩 AlertDialog - 이것이 가능합니까?
- 17. 에 AlertDialog 및 DialogPreference
- 18. 안드로이드 CountDownTimer 및 AlertDialog
- 19. Android Dev : AlertDialog with SurfaceView
- 20. Android : 백그라운드 스레드에서 AlertDialog 올리기
- 21. AlertDialog 문제
- 22. BroadcastReceiver의 AlertDialog
- 23. Android AlertDialog 스크롤 막대 위치
- 24. Android AlertDialog 생성자가 정의되지 않았습니다.
- 25. AlertDialog 채우기
- 26. 안드로이드에서 AlertDialog 프롬프트에서
- 27. AlertDialog 오버레이 닫기 Click
- 28. AlertDialog xml 파일의 위치
- 29. AlertDialog OnCLickListener가 활성화되기 위해 뒤로 버튼을 눌러야합니다.
- 30. WebView의 AlertDialog 뷰 얻기
당신은이 같은 http://stackoverflow.com/questions/1979369/을 가질 수있다, 나를 위해 작동 android-activity-a-dialog –
@ userIsAMonkey, 고맙습니다. Activity를 대화 상자로 사용하려고 생각했지만 대화를 사용하는 것이 내 작업에 적합합니다. 많은 대화가 있기를 기다리고 있기 때문에. 쉽게 보여줄 스타일이 필요합니다. 감사합니다. – oldfox3721