Android 关于改变设备方向的观点问题
当我进入横向模式时,活动底部的两个按钮不可见。屏幕应自动转换为可滚动。我是否必须向xml或清单文件添加内容Android 关于改变设备方向的观点问题,android,view,orientation,Android,View,Orientation,当我进入横向模式时,活动底部的两个按钮不可见。屏幕应自动转换为可滚动。我是否必须向xml或清单文件添加内容 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text in Hindi->"
/>
<TextView
style="@style/PassageStyle"
android:id="@+id/hindi"
android:textSize="30sp"
android:gravity="center"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Corresponding Text in English->"
/>
<TextView
style="@style/PassageStyle"
android:id="@+id/english"
android:textSize="30dip"
android:gravity="center"
/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/listen_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dip"
android:text="@string/listen"
/>
<Button
android:id="@+id/slow_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Slow"
android:layout_marginLeft="30dip"
android:layout_toRightOf="@id/listen_Button"
android:layout_alignTop="@id/listen_Button"
/>
<Button
android:id="@+id/voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/voice"
android:layout_alignLeft="@id/listen_Button"
android:layout_below="@id/listen_Button"
/>
<Button
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_below="@id/slow_button"
android:layout_alignLeft="@id/slow_button"
/>
</RelativeLayout>
</LinearLayout>
在哪里定义滚动视图 试着这样做:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
... other stuff ...
</LinearLayout>
</ScrollView>
... 其他东西。。。
我还没有使用一个,但是如果您将整个xml包装在一个ScrollView中,它应该可以正常工作
如果希望屏幕可滚动,应添加一个
滚动视图作为根布局,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_heigth="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text in Hindi->"
/>
<TextView
style="@style/PassageStyle"
android:id="@+id/hindi"
android:textSize="30sp"
android:gravity="center"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Corresponding Text in English->"
/>
<TextView
style="@style/PassageStyle"
android:id="@+id/english"
android:textSize="30dip"
android:gravity="center"
/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/listen_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dip"
android:text="@string/listen"
/>
<Button
android:id="@+id/slow_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Slow"
android:layout_marginLeft="30dip"
android:layout_toRightOf="@id/listen_Button"
android:layout_alignTop="@id/listen_Button"
/>
<Button
android:id="@+id/voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/voice"
android:layout_alignLeft="@id/listen_Button"
android:layout_below="@id/listen_Button"
/>
<Button
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_below="@id/slow_button"
android:layout_alignLeft="@id/slow_button"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
“screen应该自动转换为可滚动的。”你怎么会这么想?我还有另一个Listactivity,它可以正常工作。有没有解决上述问题的方法?ListView的内容本质上是可滚动的,这样就可以了。在线性布局中一个接一个地放置的个人视图不是。感谢您提供的信息。它很有帮助