我已經嘗試了所有可以找到的東西(在stackoverflow和網上),但我不知怎麼辦不能將我的對話框設置爲全屏。它有一個帶有文本視圖的滾動視圖,當文本視圖中沒有太多文本時,滾動視圖不是全屏。即使沒有太多可見的文字,我如何強制它全屏顯示?如何讓我的android對話框全屏?
我創建對話框如下:
final TextView box;
final Dialog info = new Dialog(cx);
final ScrollView scroll;
info.setContentView(R.layout.dialoginfo);
info.setTitle("Info");
info.setCancelable(true);
info.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
scroll = ((ScrollView) info.findViewById(R.id.scrollviewinfo));
scroll.setPersistentDrawingCache(ScrollView.PERSISTENT_NO_CACHE);
scroll.setScrollbarFadingEnabled(false);
box = (TextView) info.findViewById(R.id.infotext);
box.setText(text);
info.show();
這是XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/infolayout"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ImageView01"
android:layout_weight="1.0"
android:id="@+id/scrollviewinfo">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/infolayout2">
<TextView android:layout_margin="5dip" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/infotext"
android:textSize="8sp"
android:text=""/>
</LinearLayout>
</ScrollView>
</LinearLayout>
「info.getWindow()。setLayout(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);」做到了,非常感謝你:-)。 – HardCoder