Har*_*der 5 java android fullscreen scrollview textview
我已经尝试了所有我能找到的东西(在stackoverflow和网上),但我不知道怎么办不能将我的对话框设置为全屏.它有一个带有textview的scrollview,当textview中的文本不多时,scrollview不是全屏.即使没有多少文字可见,我怎么能强制它全屏?
我创建这样的对话框:
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();
Run Code Online (Sandbox Code Playgroud)
这是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>
Run Code Online (Sandbox Code Playgroud)
看起来您的ScrollView的高度设置为wrap_content,我首先尝试将其替换为fill_parent.
以下是一些可能对您有所帮助的其他资源:
我从来没有使用过这种setFlags()方法,所以这可能会给你相同的结果.基本上尝试更换
info.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
同
info.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
或者,如果您想要更精确地控制高度,可以创建布局参数的实例,这里的第一个答案描述如下:
如果要将其修改为略小于全屏,也可以使用此代码获取屏幕大小.
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Run Code Online (Sandbox Code Playgroud)
还有很多其他方法可以获得当前的屏幕尺寸,这只是一个例子.祝好运!
| 归档时间: |
|
| 查看次数: |
12712 次 |
| 最近记录: |