5

私はすでに(stackoverflowとネットで)見つけたすべてのものを試しましたが、どういうわけかダイアログをフルスクリーンに設定できません。テキストビューを含むスクロールビューがあり、テキストビューにテキストがあまりない場合、スクロールビューはフルスクリーンではありません。テキストがあまり表示されていない場合でも、強制的に全画面表示にするにはどうすればよいですか?

次のようなダイアログを作成します。

    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>
4

3 に答える 3

6

ScrollViewの高さがに設定されているようです。wrap_content最初に。に置き換えてみfill_parentます。

これがあなたを助けるかもしれない他のいくつかのリソースです:

ダイアログスタイルのアクティビティウィンドウを画面いっぱいに表示するにはどうすればよいですか?

私はsetFlags()この方法を使ったことがないので、これで同じ結果が得られる可能性があります。基本的に交換してみてください

info.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);

info.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

または、高さをより正確に制御したい場合は、ここでの最初の回答で説明されているように、レイアウトパラメータのインスタンスを作成できます。

警告ダイアログを画面サイズの90%に表示するにはどうすればよいですか?

全画面より少し小さく変更したい場合は、このコードを使用して画面サイズを取得することもできます。

Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();

現在の画面サイズを取得する方法は他にもたくさんありますが、これはほんの一例です。幸運を!

于 2012-05-01T14:17:39.763 に答える
0

ScrollViewのlayout_heightを"match_parent"に設定してみましたか(LinearLayoutを "match_parent"に設定することもできますが、必要ではないと思います)。「wrap_content」に設定されているので、テキストが少ないと縮小すると思います。これを試して:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    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="match_parent"
        android:orientation="vertical"             
        android:id="@+id/infolayout2"> 
    ...
    </LinearLayout>
</ScrollView>
于 2012-05-01T14:05:35.093 に答える
0

ダイアログのカスタムレイアウトを線形レイアウトではなくRelativeLayoutにラップしてみてください。それは私のために働いた。

于 2016-09-23T07:47:00.547 に答える