我有以下代码:Android的滚动型不居中
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activity_list_films">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:onClick="back"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
但是按钮,我增加了内部的LinearLayout动态的东西,都出现在屏幕的左上角。我究竟做错了什么?
我曾尝试将layout_gravity="center"
和gravity="center"
放在内部的LinearLayout中,但这没有帮助。
谢谢。
滚动型的儿童不应该有一个高度match_parent,它违背了整个目的:内容永远不会比滚动视图更大,它赢得“T滚动的建议 –
@JulienArzul感谢,并改变了代码。 –