给对话框AlertDialog添加滚动条 当AlertDialog里的内容很多时,就会看不到下面的内容,因为默认情况下,AlertDialog是没有滚动条的,无法滚动到下面去。我们今天就给AlertDialog加个垂直滚动条。 原理很简单,用绑定一个ScrollView的方式显示对话框内容。关于AlertDialog如何绑定View,请参考:AlertDialog用法续:在对话框显示View。 下面仅给出xml布局代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/updatetv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:textSize="20sp"
/>
</LinearLayout>
</ScrollView>