대화 상자의 맨 아래에 메시지와 일부 버튼이있는 대화 상자를 표시하려고합니다.대화 상자의 내용을 어떻게 감쌀까요?
대화 상자에 다른 컨트롤을 추가하여 사용자 지정보기를 사용하려고합니다. 여기
코드입니다 :hv_popup.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#ffff00">
<LinearLayout
android:id="@+id/hvBottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/btnSwitch"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MTD/HV" />
<Button
android:id="@+id/btnEDIT"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="EDIT" />
<Button
android:id="@+id/btnCancel"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CLOSE" />
</LinearLayout>
<TextView
android:id="@+id/etHV"
android:background="#000000"
android:textColor="#ffffff"
android:textIsSelectable="true"
android:textSize="12sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/hvBottomBar"/>
</RelativeLayout>
자바 코드 :
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
window.setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
dialog.setContentView(R.layout.hv_popup);
final TextView tv = (TextView) dialog.findViewById(R.id.etHV);
tv.setText("text");
dialog.show();
문제 :
etHV
에 짧은 텍스트가있는 경우 콘텐츠 높이로 줄이기를 원할 때만 화면의 전체 공간을 차지합니다.etHV
긴 텍스트가있는 경우- , 그것은 그것을 해결하는 방법을 알아낼 수 없습니다 아직도 내가 많은 솔루션 검색 화면
밖으로 버튼을 누르고, 모든 공간이 걸릴.
내 예상 결과 :- 화면의 하단에 대화 정렬
- 이 컨텐츠 높이로 대화 랩
- 버튼이 항상 내가
etHV
에 긴 텍스트를 설정 한 경우에도 볼 수 있어야합니다 . etHV
에 긴 텍스트가있는 경우에는 표시 가능한 대화 상자의 나머지 공간 만 차지하며 스크롤 할 수있게되고 대화 상자 아래쪽에있는 단추는 계속 표시됩니다.
해결책이 있습니까?
당신의 레이아웃을 바꿀 필요가 있습니다. 대화에서 원하는 것은 무엇입니까? 텍스트 버튼과 3 버튼이 맞습니까? – sravs
무엇이 문제를 일으키는 지 모르지만 https://github.com/WithoutCaps/DialogsCheatSheet에서 확인하십시오. 도움이 될 수 있습니다. (당신이 "사용자 정의 대화 상자"또는 "조각 대화 상자"작업을 완료해야합니다, 나는 "조각 대화"귀하의 경우에 더 나은 것 같아요)에 대한 몇 가지 대화 샘플이 있습니다 –