是否可以在滚动视图中添加按钮?

时间:2010-11-22 04:04:35

标签: android xml layout button scrollviewer

我在ScrollView中有一个简单的layout,以对话框格式显示About Box。所以它只是在对话框的手机屏幕上弹出。用户关闭该框的唯一方法是单击后退按钮(这是一个意图)。

我是否可以在框中添加关闭button,或者我可以让用户用手指点击屏幕上的框并将其关闭?

这是我的xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:screenOrientation="portrait"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip" >

   <TextView
       android:id="@+id/about_box"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/about_text" />
</ScrollView>

1 个答案:

答案 0 :(得分:0)

  
    

用户关闭该框的唯一方法是单击后退按钮

  

这就是任何Android用户想要做的事情。无论如何,如果你想提供“关闭按钮”功能,请记住这一点:ScrollView不能包含多个项目,因此你必须将TextView和Button包装在LinearLayout或东西。

但是,我的建议是你应该建立一个AlertDialog,它可以自动配置一个“OK”按钮,关闭对话框。